Engineering management
The original intention of Go language design is to solve the problems in engineering and design, its own Go tool is from all aspects of engineering management to consider, strive to provide perfect functions, so that the purpose of learning Go language is to solve the scenarios encountered in engineering, to avoid the different differences between academics and engineers. Go language is undoubtedly an engineering language, so what management ideas, tools and norms do Go language have in approaching engineering management? The following is strong proof that Go is an engineering language.
- Code style.
- Document Style Management
- Unit testing and performance testing
- Project engineering structure
- Cross-platform development
- Packaging distribution
Go command line tool
After the Go installation package is installed, the Gotool command line tool is automatically installed. For example, querying the installation version of the Go language is the command line tool as follows:
$ go version
go version go1
Copy the code
Generally, the help command is used to query commands. In Go, the help command is as follows:
In general, Gotool can help us do the following:
- Code formatting
- Code quality analysis and repair
- Unit testing versus performance testing
- Engineering construction
- Extraction and presentation of code documentation
- Dependency package Management
- Execute other include instructions
Code style.
“Code must be written for people to read, but incidentally for machines to execute.” This quote from Computer Programming and Interpretation is a succinct illustration of the role of code style. It hit home, good elegant code style code looking at people like bath spring breeze, a mess of code to something, I used to think if you write the code even the interns to be able to read, you write the code already very good, avenue to Jane, the language in a lot of code in the specification made mandatory demands that reduces the dispute, more simplified the problem, The programming specification of Go language mainly consists of the coding specification enforced by Go compiler and the non-mandatory coding style recommended by Gotool.
Mandatory coding specification
named
Naming rules involve naming variables, constants, global functions, structures, interfaces, methods, and so on. The Go language has the following grammatical restrictions: Any name that needs to be exposed must start with a capital letter, and any name that does not need to be exposed must start with a lowercase letter. In Java, capital letters usually start with class names, constants or global function methods rarely start with capital letters, which always makes me feel strange. In Java, camel naming is common (similar to jueJingSheQu). Variables and constants to be exposed Java will introduce a keyword modifier, Go language directly with the first letter of the case solved. The Go language explicitly supports camel nomenclature over underscores, and I’ve rarely used underscores in Java anymore, probably out of personal habit!
arrangement
Actually, I think it’s the curly braces and indentation, because Go says you can’t start curly braces on another line. To a standard permutation code: mainly uniform permutation looks comfortable.
Func Foo(a, b int) (ret int, err Error) {if a > b {ret = a} else {ret = b}}Copy the code
Remote import support
Go requires a remote jar package to be used. For example, CRC32 on Github can be used as follows:
package main
import (
"fmt"
"github.com/myteam/exp/crc32"
)
Copy the code
Before executing go Build or Go Install, just add this:
go get github.com/myteam/exp/crc32
Copy the code
After executing Go Get, we see the github.com directory in the SRC directory, which contains the myteam/exp/crc32 directory. In CRC32, that’s all the source code for the package. In other words, the go tool will automatically fetch the source code of the remote package for you and will generate the corresponding.a file in the PKG directory during subsequent compilation
conclusion
Learn here first, more also can’t remember, think of the great god said in the group of words “writing an article is a self-pleasing way, is a summary of self, not praise not to see, you write your own summary of the end of the line” quotations from Han Xuanliang is very reasonable and philosophical words. Honestly, there are very few platforms that encourage you to write and even give you gifts!!
note
This article is participating in the “Nuggets Golang Theme Learning Month”. Click here for more details.