' Code autocomplete plugin
3 Goimports will automatically delete the imported import package
4 Godef can jump to function definition
5 Gocode This is the Go Code AutoComplete plug-in after the youcompleteme will not need to click CTRL x to appear but when you hit the code automatically appear
6 Gotags This makes it easy for you to see the source code, the right part.
7 Nerdtree This allows you to view the directory structure is also very convenient
point, edit the Hellogolang.go again, syntax highlighting , save the Automatic format(using $GOBIN/GOFMT) also has, but other advanced features, such as the automatic import missing package, Auto-Completion still no, we have to continue to install some of the stuff.
3, install Go.tools Binaries
Vim-go Installation instructions mentioned that all necessary binary needs to be installed first, such as Gocode, Godef, Goimports and so on.
By: Goinstallbin
folder:$ ls. vim/bundle/vim-go/vundle.vim/At this point, edit the Hellogolang.go again, syntax highlighting , save the Automatic format(using $GOBIN/GOFMT) also has, but other advanced features, such as the automatic import missing package, Auto-Completion still no, we have to continue to install some of the stuff.3, install Go.tools BinariesVim-go Installation instructions mentioned that all necessary binary needs to be installed first, such as Gocode, Godef,
This is a creation in
Article, where the information may have evolved or changed.
Preface
Read many aspects of coding specifications, probably each company has different specifications, this code is written to my own, but also hope that our internal colleagues can follow this specification to write go code.
If your code has no way to find the following specifications, then follow the standard library specifications, read more standard library source code, the standard library is a reference to o
) return strings.NewReader(s).Read(p)}
Note has been written very clearly, let intgen this function structure to implement the reader interface, and so on will be able to write a receive reader parameters of the print function, the Intgen function as parameters passed in the
/**打印的方法让 fib 实现 Reader 接口,就可以用 print 方法打印了*/func printFileContents(reader io.Reader) { scanner := bufio.NewScanner(reader) for scanner.Scan() { fmt.Println(scanner.Text()) }}f1 := fib1()printFileContents(
package
There are several unconventional ways to introduce packages. Next I'll use it fmt as an example:
import format "fmt"-to fmt create an alias. Replace all the used content in fmt the code format.fmt.
import . "fmt"-Allow content inside the package to be fmt directly referenced without prefix
import _ "fmt"-Prevents the compiler from prompting for the introduction of fmt content without using it, and executes the initialization function in the package. A reminder that in this c
PATH for easy execution of programs under its directory
Third, Git V2.11.0.windows.1Download 64-bit Git for Windows setup, keep the default installation path (C:\Program files\git) and all the default configurations, all the way Next.
Open git bash (on the desktop right-click Git bash here) to perform the GIT basic configuration:1) User and mailboxgit config--global user.name XXXXgit config--global user.email XXXX
2) Support Long Pathgit config--global core.longpaths true
3) do not convert text
, so I highly recommend to use a common and well known plugin manager to Install Vim-go. Vim-go with other go oriented vim plugins. For pathogen just clone the repo. For other plugin managers add the appropriate lines and execute the plugin ' s install command.
pathogen
git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
vim-plug
plug ' fatih/vim-go '
neobundle
neobundle ' fatih/vim-go '
vundle
.
Install Golint:shell $ go get github.com/golang/lint $ go install github.com/golang/lint
Installing Gooracleshell go get code.google.com/p/go.tools/cmd/oracle
Installing Goimportshell go get golang.org/x/tools/cmd/goimports
Installing Gocodeshell go get -u github.com/nsf/gocode
Installing Godefshell go get -v code.google.com/p/rog-go/exp/cmd/godef go install -v code.google.com/p/rog-go/exp/cmd/godef
Installation environment often
/tools/#/goimports
Install gocode
Go get-u github.com/nsf/gocode
Install godef
Go get-v code.google.com/p/rog-go/exp/#/godef
Go install-v code.google.com/p/rog-go/exp/#/godef
During environment installation, downloading may often fail, probably because my network is not good. Problems frequently occur when connecting to google.Solution:Golang China's download channel has a third-party package download tool. After you enter t
all the used content in fmt the code format.fmt.
import . "fmt"-Allow content inside the package to be fmt directly referenced without prefix
import _ "fmt"-Prevents the compiler from prompting for the introduction of fmt content without using it, and executes the initialization function in the package. A reminder that in this case fmt is not callable
Check out this blog for more details.
Goimports
Command
This is a created
article in which the information may have evolved or changed.
Go install dependency packages typically go through four paths
1.github.com/
2.golang.org/
3.gopkg.in/
4.honnet.co/
For example, we can download the installation package via go get github.com/xxx.
After downloading, install the package via go install github.com/xxx
The installation package is downloaded to the $gopath/src file
Post-installation execution files in the $gopath/bin file
Common errors
helloworld.go
Compile and run one or more files to save the compiled results.
$ go Build helloworld.go
Get the code for another warehouse
$ go Get Gopl.io/ch1/helloworld
You need to pre-follow the versioning tools, such as Git, and set the GOPATH environment variable, and the downloaded code will be placed in the $GOPATH/src/gopl.io/ch1/helloworld directory
GOFMT Automatic Formatting
Many text editors can be set to automatically execute GOFMT when a file is saved, so your source code shou
/net/context"# CD.; Git Clone Https://code.google.com/p/go-decimal-inf.exp/tmp/chengxf/gopath/src/speter.NET/go/exp/math/dec/infCloning into '/tmp/chengxf/gopath/src/speter.net/go/exp/math/dec/inf ' ...error:failed to connect to 2404:6800:400a:805::200e:network are unreachable while accessing Https://code.google.com/p/go -decimal-inf.exp/info/refsFatal:http request failedPackage Github.com/chrislusf/seaweedfs/go/weedImports Bazil.org/fuseImports Bazil.org/fuse/fsImports Github.com/boltdb/boltImp
package)export GOPATH=/home/gopathgopm get -g -d golang.org/x/tools/cmd/goimports再使用 go install 安装 goimportsgo install golang.org/x/tools/cmd/goimports/home/gopath/bin目录下将有goimports2.3InstallationGocov(Go's unit test coverage Check tool)GOPATH=/home/gopathgopm get -g -d golang.org/x/tools/covergopm get -g -d github.com/axw/gocov/gocovgo install github.com/axw/gocov/gocov/home/gopath/bin目录下将有gocov2.4Install
github.com/golang/lint
Installing Gooraclego get code.google.com/p/go.tools/cmd/oracle
Installing Goimportgo get golang.org/x/tools/cmd/goimports
Installing Gocodego get -u github.com/nsf/gocode
Installing Godefgo get -v code.google.com/p/rog-go/exp/cmd/godefgo install -v code.google.com/p/rog-go/exp/cmd/godef
Installation environment often appear to download the problem, probably my network is not good. There are often problems conne
This is a creation in
Article, where the information may have evolved or changed.
Note: The original text is from Go-wiki to go Code Review Comments
Go Code Review recommendations
This page collects common comments from the Go code review so that a detailed description can be quickly referenced. This is a common error list, not a style guide.
You can watch effective go as a supplement.
Please discuss this change before editing this page , even if it is a small change, many people have
This is a creation in
Article, where the information may have evolved or changed.
Https://marketplace.visualstudio.com/items/lukehoban.Go
GoLukehoban| 9357 installsRich Go language support for Visual Studio CodeGet Started install*
Go for Visual Studio CodeThis extension adds rich language support for the Go language to VS Code, including:
Colorization
Completion Lists (using gocode )
Snippets
Quick Info (using godef )
G
, "autocomplete_suggest_imports": true}Install golint
Golint is used to detect Syntax problems
go get github.com/golang/lint
golint filename
Some standard errors will be prompted. You can deploy them in gosublime or fswatch.Install goimporter
go get code.google.com/p/go.tools/cmd/goimports
After compilation, set an ln-S to the $ Gobin directory (or copy the past), and add a line to the user-setting of gosublime.
"fmt_cmd": ["
and compiled meaning2.2 Install Goimports via GOPM. (Go Code formatting tool, automatically fix import of the package)Export Gopath=/home/gopathGOPM Get-g-D golang.org/x/tools/cmd/goimportsThen use go install GoimportsGo Install Golang.org/x/tools/cmd/goimports/home/gopath/bin Directory will have goimports2.3 Installing Gocov (Go's Unit Test coverage checker tool)Gopath=/home/gopathGOPM Get-g-D golang.org/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.