GO1.6 Language Learning Note 2-installation configuration and Code organization

Source: Internet
Author: User

first, about the installation and configuration of the Go development environmentTo install the compiled go installer in a Linux environment, refer to the official Guide steps step by step. It is important to note the following configuration of the environment variables: Goroot-Directory of Go compiler libraries, similar to Java java_home PATH-Pay attention to adding $goroot/bin Gopath-Go working directory, similar to Eclipse's workspace below are the specific installation steps and environment configuration $ wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz   $ tar-c/usr/local-xzf go1.6.linux-amd64.tar.gz          The installation directory is/usr/local/go, and the working directory is/usr/local/golang/work. Add environment variables to the/ect/profile file for global effect. Second, the Code organization of Go Project        Typical go working directory typically contains 3 directories       $GOPATH/        bin/  &NB Sp                              # binary execution file output Out path, typically generated automatically by Go compiler          pkg/                  &NBS P               #  Intermediate library files, automatically generated by the go compiler, sorted out by different OS architecture platforms         &NBSP ;   linux_amd64/                    # Linux 64bit    &NBSP ;       windows_amd64/               # windows 64bit   &NB Sp     src/                            &NBSP ;      # hand-created, store all go source files and store them in different sub-directories by package             GITHUB.COM/[USER]/XXX   &NBSP     # requires Git to manage versions, recommended directory structure  
    • It is recommended that all go codes be placed in a single working directory (i.e. the directory that $gopath points to)
    • A working directory can contain different version control libraries (Git repository)
    • Each version control library can contain one or more packages
    • Each package contains one or more go source files (Note that multiple go files of the same package need to be placed in the same directory, the package name must be the same, the recommended package name is the last level of the current directory path.) For example, if the go file is stored in the $gopath/src/test1/stringutil directory, the package name is Stringutil)
    • Introducing a package (import) is the path to the directory where the package is located (relative to the $GOPATH/SRC path)

GO1.6 Language Learning Note 2-installation configuration and Code organization

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.