Permalink to this article – https://ift.tt/m7ZHtqA
This article is a transcript of the live broadcast of the second issue of “The Road to Go Language Improvement” of my Go Reading Club in the GoCN community on June 26, 2022. This article has reorganized and revised the content of the live broadcast for friends who like to read the text to speculate and refer to after watching the live broadcast. Video-controlled children’s shoes can follow the GoCN official account and video account to watch the edited video, or watch the video playback in the GopherChina section of station B (https://ift.tt/KFCumHe).
Good evening everyone. My name is Bai Ming. I am the author of the book “The Road to Go Language Improvement” and a blogger of tonybai.com . Reading experience and experience.
Today’s sharing includes three aspects:
- The process of writing a book. Some Gophers may be curious about how such a thick set of books was written, so I will talk to you today.
- Introduction to “The Road to Go Language Improvement”. The main purpose is to chat with you about the overall concept of this book, hoping to help readers better read and understand this book through this guide.
- A brief sharing of my personal reading methods and experiences.
First of all, I would like to share with you the process of writing the book.
1. The process of writing a book
1. The programmer’s “small goal” and the three elements of writing a book
The children’s shoes watching the live broadcast today are all aspiring technicians, and they may have a small goal in their hearts to write a book of their own. In this way, the knowledge, skills and experience learned by oneself can be output to others in a more systematic way, which can help others to quickly learn and master the knowledge, skills and experience in this field.
Of course, there are other benefits of writing a book, such as: increasing your fame, making it easier to join the technical circle, possibly bringing you better career development opportunities, and of course, it will also bring you some additional sideline income. As for how much, it depends on Book reputation and sales.
So how can you write a book? As a “visitor”, I summed up three elements, which are also three conditions.
The first element is ability .
This is easy to understand. Take Go as an example, if you don’t have the knowledge and skills of Go language, and you don’t have a deep understanding of all aspects of Go language, it is difficult for you to write a book with a good reputation. Especially books that are original and original. It is not a compilation book that systematically organizes and excerpts the data of predecessors. Compilation of books is more common in textbooks, dictionaries, etc. Obviously, writing a book requires a higher level of authorship.
The second element is willingness .
Students who have written books all know that writing books is hard work. It requires you to devote a lot of spare time to work at your desk in your spare time. And for niche technical books, the monetary benefits of writing books are not proportional to the time and effort you put in. On this issue, I once talked with the marketing editor of the Machinery Industry Press, and the information I got was: the market of Go technical books is not comparable to Java and Python, even if it is like the Go language bible “Go Programming Language”. The sales cannot be compared with the sales of the top books of Java and Python.
The third element is opportunity .
I remember that when I was a child, I was very envious of those who could publish books, thinking that they were all god-level characters. But at that time, it was really difficult to publish a book, and there should be very few opportunities. If you were not in the academic circle, it would be difficult to publish a book. Now it is much easier and there are more channels. Every year, the publishing house has its own publishing plan, and the editors and teachers of each publishing house are also looking for matching technical authors in various self-media and technical circles according to the plan.
If you have your own ideas, you can also sort out the outline and contact the teacher of the publishing house in some way. If it matches, you can publish it.
In addition, electronic self-publishing is popular abroad, which also gives many technical authors a good publishing opportunity. For example, the Go 101 series written by the domestic author Lao Tapir is self-published on Amazon and leanpub , and the effect is not bad.
The above are the three elements of publishing a book that I have summarized. Once these three elements are gathered, publishing a book is actually a natural thing. Take me as an example.
In terms of ability, I have been in contact with and learn Go language since about 2011, and I am one of the early adopters of Go language in China. The Go language version 1.0 was only released in 2012, so when I came into contact with Go, it was still version r60, not the official version 1.0. Since then, I have been tracking the evolution of Go and writing small programs for Go projects on a daily basis.
Go 1.5 implements bootstrapping and greatly reduces GC latency, so I started using Go in some production environments, and gradually accumulated my knowledge and experience. I have been continuously outputting Go-related content on my blog, and the response has been good.
With the increase in the output of Go content, I found that the output was in the form of a blog, and the content organization was scattered, so for the first time I had the will and idea to organize and output my own Go knowledge system.
In the process of practicing Go, I received many questions from Go beginners: Go is easy to get started, but difficult to improve. How can we write high-quality code that conforms to Go thinking and language conventions like the Go development team? This question got me thinking. At the 2017 GopherChina conference, I tried to answer this question in the form of a speech with the theme of “go coding in go way” , but due to the limited length of the speech, many contents were not developed, and the effect was not ideal. This further strengthens my willingness to systematically answer this question in the form of a book.
At that time, my big treasure had grown up, and I also hoped to set a positive example for my children by writing a book. There is an old Chinese saying: teach by words and deeds , and I also want to practice them.
The opportunity just came naturally! At the beginning of 2018, Mr. Yang Fuchuan, deputy editor-in-chief of Machinery Industry Press, contacted me on WeChat to discuss whether it was possible to write a book similar to “Effective Go”. At that time, Huazhang Publishing House of Machinery Industry Press planned Effective XXX ( Write high-quality XXX) series of books. At that time, books in languages such as C and Python have been published, and they are still poor in Go language. My willingness to publish a book matched the needs of the publisher, so I agreed to Teacher Yang’s request and became the author of the Go version of this series of books.
2. The process of writing the book
I actually started writing in late 2018.
When I really started coding, I realized that writing a book is not easy, and it takes a lot of time and sweat to write a high-quality manuscript. Thinking, coding, writing code examples, drawing illustrations every night and morning with very little sleep. I remember that I was writing hard every weekend at that time, and I had very little time to spend with my family, especially my children.
In addition, I am also used to explaining a knowledge point in detail, so that the length of each section is not small. Therefore, the writing progress is very slow, and just like that, the progress is repeatedly delayed. Fortunately, the editor teacher was nice, and considering the quality of the manuscript, he did not rush the progress.
At the end of November 2020, I officially sent the first draft to the publishing community. I remember that the first draft had 66 articles and nearly 40w words.
After another year of scheduling, editing, revision, and typesetting, it will be officially published in late December 2021.
In January 2022, “The Road to Go Language Improvement” will be officially launched on the shelves of various channels.
As of today, it has been published for nearly six months, and this book has gained a good reputation. The word-of-mouth on various platforms is above 8 points (Note: The word-of-mouth score is still changing dynamically, the picture below is only a snapshot at that time, does not represent current scores).
I am very pleased to be recognized by everyone, and I feel that the hard work in the process of writing the book has not been in vain.
This is my writing process. In a word: writing a book is not easy, and writing a high-quality book is even harder .
Next, I will take a look at the introduction of the book “The Road to Go Language Improvement”.
2. Introduction to “The Road to Go Language Improvement”
Maybe it’s “too hard”, “The Road to Go Language Improvement” is too thick to be bound into one volume. The editor suggested that the book should be bound into two volumes, namely volume 1 and volume 2. Many students wondered why it was not Volume 1 and Volume 2 but Volume 1 and 2. Here is the editor’s “far-sighted vision”, the purpose is to leave enough space for possible “continuation” (such as Volume 3) in the future. After all, the Go language is still evolving rapidly. , the current version does not yet contain new syntaxes like generics . However, Book 3 is not yet planned.
This set of books is divided into 10 parts and 66 topics. The first volume contains the first 7 parts, and the last 3 parts are in the second volume.
1. Overall writing ideas
The whole set of books revolves around two related ideas.
The first idea I call it: the path of diligence, thinking first .
The second line of thought is called: practicing philosophy, following conventions, recognizing the essence, and understanding the principles .
Let’s take a look at the first idea.
2. The road of improvement, thinking first
The children’s shoes watching the live broadcast have learned more than one programming language. Everyone may have had this experience: you are proficient in language A, and then use the thinking of language A to write B code when learning B language, you will feel that the B code you write is very awkward, and the code you write always feels like Not very authentic, I always feel that it is not the kind of high-quality B language code.
In fact, not only learning programming languages, but also learning natural languages. The most typical example is that everyone has studied English for more than ten years, but there are not many people who can express their opinions in authentic English after graduation. Why? That is, we always use the Chinese way of thinking to organize English sentences and speak English, so no matter how hard we try, it will be difficult to get to the next level.
In fact, many language masters have long realized this. The following are the arguments about language and thinking of these masters that I have collected, and I will share with you here:
“Language determines the way of thinking” – Sapir hypothesis
“The limits of my language are the limits of my world” – Ludwig Wittgenstein, founder of the philosophy of language
“A language that doesn’t change the way you think is not worth learning” – Alan Perlis (inaugural ACM Turing Award winner)
We see: whether it is a master in the natural language field or a big man in the IT field, their views are similar. In a word: language must be refined, and thinking must be advanced .
3. Part1: Entering the Go language programming thinking guide
It is precisely because I realize the close relationship between language and thinking that I arranged the Go language programming thinking guide in the first part of the book. I hope everyone realizes the importance of Go programming thinking on the road to language improvement.
The thinking of a programming language is not innate, but gradually formed in the evolution. So in this part, I arranged the birth and evolution of Go, and the design philosophy of Go: simplicity, composition, concurrency, and engineering orientation. The purpose of this is to let everyone understand the thoughts of Go language designers when designing Go language, so that readers can understand the unique design of Go language from the height of language designers, and agree with the design concept of Go language. Because these are the “soil” from which the thinking of the Go programming language is formed .
The last section of this part is an example guide for Go programming thinking. The book gives the thinking methods that C, Haskell and Go programmers first consider when facing the same problem and the differences in code design methods under different thinking.
Knowing the importance of Go programming thinking, what should we do?
4. How to learn Go programming thinking?
The essence of learning is an imitation. To learn Go thinking, you need to imitate the excellent projects and code of the Go team and the Go community and see how they do it . That’s what the rest of the book is about. And “practice philosophy, follow conventions, recognize essence, and understand principles” is a brief summary of the writing ideas of the following content.
- practice philosophy
Use the Go design philosophy in the design practice of your own projects, not just know it by word.
- follow the convention
Follow some of the Go team’s language conventions, such as “comma, ok”, use compound literal initialization, etc. Using these conventions you can make your code appear idiomatic, and others will understand it at a glance.
- recognize the essence
In order to use language mechanisms more efficiently, we need to recognize the essence behind some language mechanisms, such as the representation of slices and strings at runtime, which can not only help developers use these syntax elements correctly, but also avoid pitfalls .
- understand the principle
Go comes with a runtime. The runtime participates in the entire Go application life cycle. Therefore, only by properly understanding the principles of Goroutine scheduling and GC, can the power of Go be fully utilized.
Part2-part10 of this book is based on the sorting out of the best practices and conventions of the Go team and the Go community, constructed with systematic ideas and presented to everyone step by step.
5. Part2 – Project Basics: Layout, Code Style and Naming
The content of this department is something every gopher should consider when starting a Go project.
- Project layout
I’ve seen a lot of Gopher asking about project layouts because Go doesn’t officially give a standard layout. This book explains the evolution of the structure and layout of the Go project and the de facto standards of the Go community, hoping to provide you with enough reference information.
- code style
For the Go code style, since the code style has been weakened in Go, here is the main point to show you the meaning and usage of gofmt.
- naming convention
Regarding naming, I don’t know if everyone thinks it is difficult to name, but it is quite difficult for me. I always rack my brains on what name to use (manually allow sadness). So my principle is “code not moved, name first”. For “critical issues” such as naming conventions for variables, identifiers, etc. in Go, I used a “stupid method”: I counted the naming of the Go standard library, Docker library, and k8s library, and classified them into different syntax elements. The naming convention of , you can read the book to understand the specific content.
6. Part 3 – Syntax Basics: Declarations, Types, Statements and Control Structures
The third part is very basic, but the content is still higher than the basics.
- Consistent variable declaration
We know that Go provides a variety of variable declaration methods, but which declaration method should be used in different locations, which is readable and not easy to create pits (especially pay attention to short variable declarations)? The book gives a systematic explanation.
- Untyped constants and iota
Everyone has used constants, but many people do not understand the difference between untyped constants and typed constants. The book summarizes them for you. Also, many people have used iota without understanding what iota really means and what it can do for you. The book explains the semantics of iota and sorts out common uses.
- zero value available
Go advocates that zero values are available, and there are many built-in types that are available with zero values, which are very cool to use, such as: slices (not all, only zero values are available when appending, when accessing with subscripts, no zero values are available) , Mutex, RDMutex, etc. in the sync package
In fact, analogous to thread (thread), goroutine is also a “type” with zero value available, but Go does not have the type of goroutine.
If we are the designer of the package, we can improve the experience of the user of the package if we provide a type with zero value available.
- compound literal to initialize
It is a Go language convention to use compound literals to initialize corresponding variables. Although Go provides new and make, they are rarely used in daily life, especially new.
- Principles, idioms and pits of slices, strings, and maps
Go is a language with runtime, and many syntax elements displayed at the syntax level are inconsistent with the real representation of the runtime layer. To use these types efficiently, it is not enough without understanding the runtime layer representation. Sometimes there are serious “pits”. Understand, you can naturally bypass the pit.
- package import
Is the import statement of a Go source file followed by the package name or the package path? Does Go compilation have to have the source code of the dependencies, only .a can? These question books are systematically explained
- Code Blocks and Scope
Code blocks and scopes are the basic concepts of the Go language. Although they are basic, if they are not well understood, there are also “pits”, such as the most common variable shadowing. Once fully understood, it can also help you solve unexpected syntax problems and execution semantic errors.
- control statement
Go advocates “there is only one solution to a problem”. Go provides only one syntactic form for each control statement. Although there is only one form, if it is not used well, the same container will fall into the pit. This set of books summarizes the idioms and usage precautions of Go control statements.
7. Part4 – Syntax Basics: Functions and Methods
The Go code logic we write every day is in functions or methods, and functions/methods are the basic bearing units of Go program logic.
- init function
The init function is a function that is executed during package initialization and has many special uses. And its initialization sequence also has an impact on program execution semantics, so it is necessary to clarify this aspect. The book sorts out the common uses of the init function, such as the driver self-registration mode of the database/sql package.
- Become a “first-class citizen”
In Go, functions become “first-class citizens”. After a function becomes a first-class citizen, it can be passed to the function as a parameter, returned from the function as a return value, and assigned to other variables as an rvalue, etc. The book systematically explains the properties and special applications of this feature. , such as functional programming, etc.
- Idioms and pits of defer statements
defer is to help you simplify the code logic. The book summarizes the application mode of defer statement. And the precautions for using defer, such as function evaluation timing, usage overhead, etc.
- variadic function
Go supports variadic functions. You may not realize that variable-length parameter functions are the most commonly used functions, such as the append function, the fmt.Printf series, and the functions provided in the log package to output logs by log severity level.
But the variable-length parameter function may also be a type of function form that we design and implement less by ourselves. What can variadic functions do for us? The book explains the common uses of variable-length parameter functions, such as implementing function option patterns.
- The essence of the method, receiver parameter type selection, method collection
The essence of a method is actually a function, and figuring out the essence of a method can help us solve many difficult problems. The book uses examples to help you understand this.
The choice of the method receiver parameter type is also a common confusion for Go beginners. Three principles are given in this book. With reference to these three principles, the receiver type selection is not a problem.
How to determine if a type implements an interface? We need to look at the type’s method collection. Then it is very important to determine a type method set, especially those method sets that include types embedded in the type, which is systematically explained in the book.
8. Part5 – Syntax Core: Interfaces
- the internal representation of the interface
Interfaces are an important syntax in the Go language. Russ Cox once said, “If I had to pick a feature out of Go and put it in another language, I would choose interfaces”. The importance of visible interfaces. However, the premise of making good use of interface types is to understand the representation of interfaces at the runtime layer. This section will detail the internal representation of empty and non-empty interfaces.
- interface design conventions
What kind of interface should we design? What are the disadvantages of large interfaces? What are the advantages of small interfaces? How small is a reasonable interface? These are explained in this section.
- Interface and composition
Composition is the design philosophy of Go, and Go is a language about composition. Interfaces play an important role in composition-oriented programming. Here I will mention two ways of composition in Go: vertical composition and horizontal composition. Among them, the interface type plays a key role in the horizontal composition. The book also explains several modes of horizontal composition through interfaces: wrapping mode, adapter function, middleware, etc.
Many beginners tell me that they have been coding in Go for a while, but have not yet designed the interface themselves. I recommend such students to read this part carefully.
9. Part6 – Syntax Core: Concurrent Programming
- Concurrent Design vs Parallel Design
To learn concurrent programming, you must first understand the concepts of concurrency and parallelism. The book uses a very vivid example of airport security to tell you the difference between concurrency and parallelism. Concurrency is about structure, parallelism is about execution
- Principles and Application Patterns of Concurrency Primitives
Go implements the csp model and provides goroutine, channel, and select concurrency primitives.
Understand go concurrent programming. First of all, we must deeply understand the concurrency model and scheduling method based on goroutine. The book explains this in a simple way, without involving too much code, I believe everyone can understand it.
The book also compares the go concurrency model, one is csp, the other is the traditional shared memory-based method, and lists the common modes of Go concurrency, such as creation, cancellation, timeout, pipeline mode, etc.
In addition, as a standard primitive for communication between goroutines, channel has many ways to play. Here are the common patterns and precautions for use.
- Low-level synchronization primitives (sync and atomic)
Although the concurrency primitives of the CSP model greatly simplify concurrent programming, the sync package and atomic operations cannot be forgotten. Many performance-sensitive critical sections also require low-level synchronization primitives such as sync package/atomic to synchronize.
10. Part7 – Error Handling
The reason that error handling is singled out is because many people, especially children’s shoes from java, are accustomed to the structured error handling of try-catch-finally, and seeing the error handling of go makes them a headache.
The Go language takes error handling very seriously, but it does have a relatively conservative design and conventions for explicitly handling errors.
This section covers common Go error handling strategies, avoids writing too many if err != nil solutions, and more importantly, the difference between panic and error handling. I have seen too many students who use panic as normal processing. Especially the children’s shoes from the java camp.
11. Part8 – Programming Practices: Testing, Debugging and Profiling
This section focuses on Go toolchain engineering practices outside of coding.
- Go testing conventions and organization
In this part, we will first talk about the organization of the go test package, including whether to choose an in-package test or an out-of-package test? When to adopt table-driven test case organization that conforms to go conventions? How to manage external data files that tests depend on, etc.
- Fuzzing tests.
The fuzzing test here is not based on the native fuzzing test of go 1.18. When the book was written, the go 1.18 version had not been released, but it was based on Dmitry Vyukov’s go-fuzz tool .
- Performance benchmarks, metrics and pprof profiling
Go natively provides performance benchmarks. This section explains how to do performance benchmarks, how to write serial and parallel tests, tools for comparing performance benchmark results, and how to remove extra distractions to get more accurate results. When explaining the pprof performance profiling tool, I use an example to analyze and explain, so that it is more intuitive to understand.
- Go debugging
When it comes to Go debugging, the most common estimate we use every day is the print method. But in addition to the print method, there is actually a de facto standard Go debugging tool, which is delve. In this section, I explained how delve works and how to use delve to implement concurrent debugging, coredump debugging, and debugging of online attach processes.
12. Part9 – Standard Library, Reflection and cgo
go is a battery-powered, out-of-the-box language with a high-quality standard library. Some Gophers in foreign countries even advocate relying only on the standard library to implement go applications.
- Frequently used standard library packages (net, http, strings, time, crypto, etc.)
In this section, I disassemble and analyze the principles and usage of frequently used standard library packages, such as net, http, standard library io model, strings, time, crypto, etc. to help you use the standard library more efficiently.
- The three rules used by the reflect package
The reflect package provides reflection capabilities for go. The book explains the implementation principles of reflection, focusing on the three principles used by reflect.
- cgo use
cgo is not go, but the cgo mechanism is the only means of interacting with c using go. The book explains the usage and constraints of cgo in detail, especially how to do static compilation when cgo is enabled is worth reading carefully.
- Safe use of unsafe packages
Facts have proved that the unsafe package is very useful, but to safely use the unsafe package, especially unsafe.Pointer, you need to follow certain rules of safe use. The book gives detailed examples of this.
Reflection, cgo, and unsafe are advanced topics. To understand them thoroughly, you need to read the contents of the book several times and combine them with practice.
13. Part10 – Engineering Practice
- go module
The go module was introduced in go version 1.11 and became the official default build mode of go in version go 1.16 . Go programmers get started with go, and advanced go can’t cross the hurdle of go module. The book provides a super-systematic explanation of the go module construction mode: from the evolution history of the go construction mode, the concept, principle, and convention of the go module, the operation of upgrading and upgrading major versions, and the precautions for use. However, there are still some flaws here, that is, the position of the go module section is placed too far back, so it should be mentioned earlier. If there is a later revision, consider doing so.
- Custom go package import path
The book also gives an implementation of a custom go package import path, which is very suitable for private warehouses within the organization. Interested students can focus on it.
- Detailed explanation of the usage mode of the go command
This section details the go commands by category. include:
- 获取与安装的go get/go install - go包检视的go list - go包构建的go build - 运行与诊断的GODEBUG、GOGC等环境变量的功用- 代码静态检查与重构- 文档查看- go代码生成go generate
- Common “pits” in Go
This section reviews Go’s common “pits”. Here I divide the pits into “grammar category” and “standard library category”, and draw on CCTV’s five top 10 football programs in the world, and comment on the “pitfall index” and “pit damage index” of each pit.
14. Have complete sample code and errata
This set of books has complete sample code and errata , and they are all maintained continuously, so that everyone has no worries about reading.
3. Practice and experience of reading
Next, I will share how I personally read, including the reading process of go technical books, as well as some practical experience about reading.
Reading is a matter of thousands of people, and there is no fixed standard. My way of reading may not be suitable for you. You can listen to it, you think it’s not bad, it’s the best if you can learn from it.
Today’s live broadcast is estimated to be dominated by gopher, so let’s talk about the reading process of Go language books first.
1. Go language book reading process: first outside and then inside
For IT technology books, you still need to look at the original version in the initial stage. This is no way, because the vast majority of it programming technology comes from abroad.
The first Go technical book I read was “the way to go”, which has not been introduced into China so far. This is a Go language encyclopedia, and most of it still applies today. The only shortcoming is that the book was written before the release of Go 1.0, it seems that the r60 version was used, and a small part of the content is no longer applicable.
After Go 1.0 was released, I also read “programming in go” and “The Go Programming Language Phrasebook” by Addison-Wesley, both of which were good.
At the end of 2015, Brian Kernigan and Donovan of the go core team co-authored “The Go Programming Language”. The book called the Go Bible in China was published, which made the foreign language go technology books reach their peak. There are also go books published one after another, but none of them can touch the status of the go bible.
After talking about foreign language books, let me talk about the reading process of Chinese Go books.
The first Chinese Go book I read was “Programming in Go Language” by Mr. Xu Shiwei in 2012. I admire Mr. Xu’s vision and courage. Qiniuyun has been using go in production for a long time.
The second Chinese Go book is Teacher Yuken’s “Go Study Notes”, which is also the first book in China that goes deep into the underlying principles of go (the second half). Unfortunately, the book stays at go 1.5 (or go 1.6). In terms of implementation, it has not been continuously updated with the evolution of the Go version.
“Advanced Go Programming” co-authored by Chai Da and Cao Da is also a good go technical book. If you want to learn cgo and go assembly in depth, it is recommended to read this book.
The following “Analysis of the underlying principles of the Go language” and “Go language design and implementation” are also books aimed at in-depth understanding of the operating mechanism of Go, and they have a good reputation. Gophers who are interested in this aspect can choose any book. study.
2. Your own way of reading
My reading method is actually not complicated, mainly divided into intensive reading and extensive reading.
- Reading method: Intensive reading of good books, extensive reading of idle books
Good book to read over a long period of time. Xianshu (no brain-burning), usually fragmented reading.
- Intensive reading method: excerpt + brain map + action list
An excerpt is to extract the views and details from the book, put them in the reading notes, and preferably re-describe them in their own words, so as to make a deep impression and a more thorough understanding.
The brain map summarizes the thinking context of the book and prevents you from forgetting after reading it. Through the brain map, I can at least look at the context and remember it.
Action Checklist: This book doesn’t mean much to you without outputting an action checklist. What is a good book? A good book is one who is eager to do something based on the ideas in the book after reading it. The action list will help me to understand the content of the book repeatedly in the follow-up actions, improve the digestibility of knowledge and the depth of understanding.
- Extensive reading method: fragmentation + listening to the book
Extensive reading is mainly fragmented fast reading or listening to books, mainly when taking the subway, bus, or walking. Under the premise of ensuring safety while driving, you can use the method of listening to the book.
4. Summary
This time, three pieces of content are shared, and here is a summary:
- The process of writing a book and the three elements of writing a book: ability + willingness + opportunity;
- Introduction to the Go Progressive Road: Think first, practice philosophy, follow conventions, recognize the essence, and understand the principle;
- Reading method: Select high-quality books for intensive reading (brain map + detailed excerpt + action list).
5. Q&A
- Is there any elegant way to handle errors in actual development?
It is recommended to read the content about error handling in the seventh part of the first volume of “The Road to Go Language Improvement”.
- Do you have experience dealing with hexagonal architecture and dependency injection in your work?
The hexagonal architecture has not been used yet, and the Go third-party dependency injection solution has not been used in production.
- Will generics and fuzzing be added later?
From the perspective of the comprehensive coverage of the book content, I personally have the idea of supplementing the above content, but it also depends on the current sales of this set of books and the plan of the publisher. It has not yet been included in the personal work plan.
- It is very practical for the author to summarize a series of go methodologies, conventions, etc. How did such logical thinking and insights come to be?
I didn’t really think about how it came about. I usually like to ask myself a few whys to form a work and study logic that convinces me. (Additional text: empathy, summarizing more, reviewing more, and outputting more).
To learn Go conventions and methodology, you can read more about the code review of the Go language open source project itself, and see how Go contributors write code and how to review the code of other contributors. (Additional text: In this process, I have a subtle feeling of Go programming thinking).
- How to read the source code of a large go project?
My personal approach is top down. First split the structure, and then find the entrance. If it is an executable go program, look backwards from the entry level. Then use some tools, such as the function call tracking tool I developed before, to view the function call sequence during program execution.
For more details, you still have to dig into the code to see.
- Opinions on some design patterns in Go projects? How to use design patterns and what to pay attention to when using them?
Design patterns are not something that is often mentioned in the Go language. One of my previous points: In other languages, design patterns that require you to build with some extra careful design are something that comes naturally in Go.
In my daily coding process, I don’t think too much from the perspective of how to apply design patterns, but according to the go design philosophy, I consider concurrent design and combination design, instead of applying those 23 classic design patterns.
“Gopher Tribe” Knowledge Planet aims to create a high-quality Go learning and advanced community! High-quality first published Go technical articles, “three-day” first published reading rights, analysis of the current situation of Go language development twice a year, reading the fresh Gopher daily 1 hour in advance every day, online courses, technical columns, book content preview, must answer within 6 hours Guaranteed to meet all your needs about the Go language ecosystem! In 2022, the Gopher tribe will be fully revised, and will continue to share knowledge, skills and practices in the Go language and Go application fields, and add many forms of interaction. Everyone is welcome to join!
I love texting : Enterprise-level SMS platform customization development expert https://51smspush.com/. smspush : A customized SMS platform that can be deployed within the enterprise, with three-network coverage, not afraid of large concurrent access, and can be customized and expanded; the content of the SMS is determined by you, no longer bound, with rich interfaces, long SMS support, and optional signature. On April 8, 2020, China’s three major telecom operators jointly released the “5G Message White Paper”, and the 51 SMS platform will also be newly upgraded to the “51 Commercial Message Platform” to fully support 5G RCS messages.
The famous cloud hosting service provider DigitalOcean released the latest hosting plan. The entry-level Droplet configuration is upgraded to: 1 core CPU, 1G memory, 25G high-speed SSD, and the price is 5$/month. Friends who need to use DigitalOcean can open this link : https://ift.tt/WktiECe to open your DO host road.
Gopher Daily Archive Repository – https://ift.tt/AiMGgtD
my contact information:
- Weibo: https://ift.tt/wzOD1Rh
- Blog: tonybai.com
- github: https://ift.tt/5IvXDxP
Business cooperation methods: writing, publishing books, training, online courses, partnership entrepreneurship, consulting, advertising cooperation.
© 2022, bigwhite . All rights reserved.
This article is reprinted from https://tonybai.com/2022/07/07/gocn-community-go-book-club-issue2-go-programming-from-beginner-to-master/
This site is for inclusion only, and the copyright belongs to the original author.