goweb- installation and configuration go go

Installation and configuration go go

Installation go

When writing this blog, my computer windows already installed the go, using a standard package is installed, but my linux operating system is not installed, consider installing a third-party tool, because goweb read this book, I know there are three ways to install go. This book installation of three operating systems have introduced

  • Go Source Installation: This is a standard software installation. For frequent users of Unix-like systems, especially for developers, you can customize their installation from source.
  • Go standard package installation: Go provides a convenient installation package, support for Windows, Linux, Mac and other systems. In this way suitable for quick installation, you can download the appropriate installation package is good, all the way next you can easily install the system according to their own figures. Recommend this way
  • Third-party tools installation: There are many third-party software packages convenient tools, such as Ubuntu's apt-get and wget, Mac's homebrew and so on. This installation for users who are familiar with the respective systems.
    If you want to install multiple versions of Go in the same system, you can refer to third-party tools GVM, which is currently doing the best tools in this area, unless you know how to handle.

Windows system users press Win + R Run cmd, input systeminfoEnter, wait a moment, there will be some system information. In the "system type" row, when displaying "x64-based PC", that is, 64-bit system; if "X86-based PC", compared to 32-bit display system.

Apple did not look at me, because I did not Apple, O (∩_∩) O haha ​​~

There are taught how to configure the environment variables on linux, nice! The installation of third-party tools is gvm. This third party knew it, I was on the third-party tools installed on Windows, but in fact pages does not matter, this does not affect me go use on Windows

export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=$HOME/gopath (可选设置)

go features

Go is a new language, a concurrent, with garbage collection, fast compiler language. It has the following features:

  • It can compile a large Go program with a few seconds on a single computer.
  • Go provides a model for software construction, it makes dependency analysis easier, and avoids the beginning most of the C-style include files and libraries.
  • Go is a statically typed language, it's not the type of system level. Thus the user does not need to spend time on the relationship between types, so that feels more lightweight than a typical object-oriented language.
  • Go totally garbage collection type of language, and provides basic support for the concurrent execution and communication.
  • In accordance with its design, Go intends to provide a method for the configuration of the multi-core machine system software.

Go is a compiled language, which combines the ease of interpreted languages, dynamically typed language development efficiency, and safety of static typing. It also intends to become a modern, language support network and multi-core computing. To meet these goals, the need to address some issues of language: a rich expressive but lightweight type system, with concurrent garbage collection, strictly dependent on specification and so on. These can not be solved by good libraries or tools, Go also came into being.

go command relies on a critical environmental variables: $ GOPATH

GOPATH allows multiple directories, when there are multiple directories, please note that the delimiter, when multiple directories is a semicolon for Windows, Linux system is the colon, when there are multiple GOPATH, the default content will go get placed on a directory.

Gofatः

More than $ GOPATH catalog convention has three subdirectories:

  • src storing source code (for example: .go .c .h .s, etc.)
  • pkg compiled files generated (for example: .a)
  • bin generating the compiled executable file (for convenience, can be added to the directory $ PATH variable, if there are multiple GOPATH, then use the $ {GOPATH //: // bin:} / bin add all bin directory)

Note: generally recommended package names and directory names consistent

It talked about how to install and compile a go application, I have not seen it, he wrote that a package has installed this package, but also out of the package, and write it in a folder in the package the folder references this package is not the same thing, I do not quite understand the meaning of this done.

Tools and plug-ins

Utilities: Remote Access package: go get github.com/astaxie/beedbit can be understood as the first step through the first source code into src clone tool below, and then do go install, how to use the remote code on the package go get in nature, and is very simple to use as a local package as long as at the beginning of the path you can import the corresponding import "github.com/astaxie/beedb"to the practice of this front seems a bit understand
go get -u parameters can be automatically updated packages, and other third-party packages will automatically get the package depends on when go get a

bin directory is stored after compiling an executable file, the application is stored below pkg package, the following is saved src application source code

go of tools is really amazing:

go test
go build
go install 
go clean
go fmt
go get
go tool
go generate
godoc
go version 查看go当前的版本
go env 查看当前go的环境变量
go list 列出当前全部安装的package
go run 编译并运行Go程序

Way of looking at the official documentation methods: through the command line execution godoc -http =: port number such as godoc -http =: 8080. Then open 127.0.0.1:8080 in your browser, you'll see a local copy version golang.org, through which you can check the contents of pkg other documents. If you set GOPATH, under pkg classified document not only lists the standard package, you will be listed in the local GOPATH related documentation for all projects for which the user is often the wall is a good choice.

Editor: There vscode, sublime, atom and LiteIDE on my computer, I generally vscode, hee hee hee, the book of related plug-ins Each editor to do a brief introduction.

I had to, go a lot of useful plug-in installed language is not on the air!

This chapter describes how to install Go, Go can be installed in three ways: source installation, standard installation packages, third-party tools installed, after installation we need to configure our development environment, and then describes how to configure local $ GOPATH by setting $ GOPATH after the reader can create a project, then it describes how to compile the project, application installation and other issues, these need to use a lot of the Go command, so then they introduce some common commands Go tools, including compilers, installation , formatting, testing command, and finally introduces the development tools Go, Go there are many development tools: LiteIDE, Sublime, VSCode, Atom, Goland, VIM, Emacs, Eclipse, Idea and other tools, according to their own readers may be familiar with tools for configuration, hoping to quickly develop applications Go through a convenient tool.

address

Guess you like

Origin www.cnblogs.com/ygjzs/p/12189492.html