当前位置:网站首页>Go questions / knowledge gathering - 2
Go questions / knowledge gathering - 2
2022-06-09 08:01:00 【A boy in plain white】
1. Application scenarios
| Mainly used to collect Go Knowledge , Temporary storage . |
2. Study / operation
1. Document readingsource code https://github.com/bigwhite/publication
2. Organize output------------------------------------------------------------ Separator ------------------------------------------------------------ 12| Basic data type :Go What are the natively supported numeric types ?- Geek time
1. Net friend - Roger float It's actually quite complicated , If you can avoid it in development, you can avoid it , For example, the monetary unit is only US dollars or RMB. I suggest using cents as the unit .
2. Net friend -liaomars
3. Net friend - Sheep and sheep 0x1.Fp+0 // 1.9375 * 2^0 = 1.937500 How is this calculated ?0x1.F=1.9375 How to get it ?
4. Net friend -qinsi ---- I don't understand very much for the time being , Continue to learn , understand --- Calm down 16777216.0 = 2^24 = (1+.0) * 2^24 The netizen added his own comments : qinsi Floating point numbers are often understood as decimals that can be used to represent integers , However, the format of floating-point numbers determines that the interval between adjacent floating-point numbers will increase with the increase of floating-point numbers . With float32 For example , As the exponent increases to near the mantissa bit Count , The interval between floating-point numbers is from 2^(-23), Gradually rise to 2^(-3)=1/8、1/4、1/2 and 2^0=1, If it continues to increase, the interval will continue to expand to 2^1=2、4、8,…, This starts skipping some integers . At this time, it is contrary to the recognition that floating point numbers are usually used to represent decimals .
5. Net friend -jc9090kkk type Myint int32 What are the advantages of this custom type in practical application ?
Other netizens -tequ1lAneio Hello Teacher , In which scenarios will type aliases be used ?
Net friend -Howe teacher , What are the application scenarios for custom types and type aliases ? For example, customize a type , In essence int32, Then why not use it directly int32, It looks like a little grammar sugar , Not very useful , In particular, type aliases
6. Net friend - Vfeelit Many languages do not have unsigned integers Whether unsigned integers are necessary ? in addition , No unsigned floating-point numbers , Is it unnecessary
The above question is a bit convoluted , Personal brevity problem 1: Can we not use unsigned integers ?-- Use less , But it still needs to be . problem 2: Can you not use unsigned floating-point numbers ?-- From the representation principle of floating point type , Sure . 7. Net friend -Niverkk In the text Go use 2 Complement (Two’s Complement) Bit coding method as an integer
8. Net friend - I'm Baolong 、 type Myint int
------------------------------------------------------------ Separator ------------------------------------------------------------ 13| Basic data type : Why? Go To natively support string types ?- Geek time Exercises after classGo Provides a variety of string connection services , Including based on +/+= Character connection of 、 be based on strings.Builder、strings.Join、fmt.Sprintf And other functions to connect strings . that , Which connection mode has the highest performance ? Net friend - Sword clasping scholar Connect 5 m helloworld
1. Vfeelit rune yes int32 Alias Unicode Coding is not negative Why not uint32 Another name for ?
2. How are you? , friend . It can be understood as []rune Deposit is Unicode Code point or UTF-32 code , and []byte and string Deposit is UTF-8 code
3. lesserror Tony Bai The teacher's article is about Go The explanation of string types is very detailed .
4. qinsi So here comes the question ,raw string How to use backquotes in ?
5. Bynow & and unsafe.Pointer What's the difference? ?
6. Multiple parameters teacher , About utf-8 Do not consider the problem of byte order . Can you understand ,utf-8 A character of is composed of 3 Bytes are encoded and compared byte by byte , For example, the value encoded by the first byte is between these values , It must be single byte encoding , The second byte encodes a value between , That must be double byte encoding , and utf-32 need 4 Bytes together ? that , once 4 If the bytes are considered together , It is necessary to involve this 4 Is a byte a large endian or a small endian ?
I'm Baolong 、 Hello, teacher , A Chinese character stay utf-8 The encoding is followed by three bytes , Why is there no byte order problem , I'm a little confused
7. Sheep and sheep var s string = "hello"
8. light What is the difference between these two ways of writing .
9. Elvis Lee string It's a 8 A collection of bits and bytes , Usually but not necessarily UTF-8 Encoded text .string Can be null , But not for nil.string The value of is unchangeable .
10. Multiple parameters The teacher told me that coding is the clearest thing I have ever seen . There's a little problem , Namely Go Medium string What is stored in memory should still be UTF-8 Encoded data ? and rune The way we use it Go The source code is implicitly converted ? The author replied : you 're right ,string What is stored in memory is utf8 Encoded bytes . image for range The result of this cycle rune, yes Go Compiler replacement at compile time . 11. Evolutionary bacteria String is a very common thing , I can't help thinking ,go There should also be the problem of garbled strings ?
12. Sheep and sheep Second point : There is no end ’\0’, And the time complexity of obtaining the length is constant , Eliminates the overhead of getting string length . The time complexity of getting the length of string bytes is O(1) Well ? If you use utf8 Library function utf8.RuneCountInString() Gets the character length of the string , I don't know the time complexity
13. Roger About splice performance , Is there any authoritative article about , I compared the results of the test fmt.Sprintf Basically the worst
------------------------------------------------------------ Separator ------------------------------------------------------------ ------------------------------------------------------------ Separator ------------------------------------------------------------ ------------------------------------------------------------ Separator ------------------------------------------------------------ ------------------------------------------------------------ Separator ------------------------------------------------------------ Subsequent complement ... |
3. problem / Add
TBD |
4. Reference resources
12| Basic data type :Go What are the natively supported numeric types ?- Geek time 13| Basic data type : Why? Go To natively support string types ?- Geek time |
Subsequent complement
...
边栏推荐
- Apache configuration and application (building web host, log segmentation and awstats analysis system)
- (十三)valgrind在ARM上交叉编译和内存泄漏检测
- ehcache
- redis核心知识点总结(超详细)
- Summary of MySQL knowledge points
- A collection of common test terms
- [penetration test] summary of conditional competition vulnerabilities
- How about opening an account for shares of tongdaxin? Is it safe to open an account?
- C language review 11
- (13) Cross compilation and memory leak detection of Valgrind on ARM
猜你喜欢

Selenium: Introduction

Compiling opencv4.5.5 with CUDA (4.2.0+cuda11.1+cudnn8.0.5 failed)

Use of Shopify port in EDI system of bridge of knowledge and Practice

2022 tower crane driver (construction special type of work) examination question simulation examination question bank and simulation examination

Apache configuration and application (building web host, log segmentation and awstats analysis system)

PostgreSQL database replication - background first-class citizen process walreceiver ready_ to_ display

Oracle: time type

Taobao classification encyclopedia and its grouping (mysql, XLS) files, hierarchical relationship, spelling, hierarchy, hierarchical tree, tips, data on February 28, 2022

YOLOv5添加注意力机制的具体步骤

C语言复习7
随机推荐
Report on Market Research and future forecast of Chinese pharmaceutical rubber stopper (2022 Edition)
Two ways to achieve single sign on
84.1%受访家长感到身边喜欢用电子产品哄孩子的家长多
2022 Chinese cook (elementary) examination question bank and online simulation examination
Epoll series system call
C语言复习7
Force to trigger epollin and epollout events
2022 tower crane driver (construction special type of work) examination question simulation examination question bank and simulation examination
2022 examination questions and mock examination for the third batch of Guangdong Provincial Safety Officer C certificate (full-time safety production management personnel)
Robot_ Framework: Variables
Market Research - current situation and future development trend of Brazil berry oil market in the world and China
ftp服务
At time_ What happens to TCP connections in wait status after SYN is received?
Apache configuration and application (building web host, log segmentation and awstats analysis system)
C语言复习12
苹果胜诉 法官驳回iPhone安全欺诈集体诉讼
C language review 10
R language through rprofile Site file, custom configuration of R language development environment startup parameters, shutdown parameters, use file Edit function edit configuration file
FTP service
How about opening an account for shares of tongdaxin? Is it safe to open an account?

