Goroot, Gopath and go get

Source: Internet
Author: User
Tags install go git shell
This is a creation in Article, where the information may have evolved or changed.

1. Goroot Gopath and PATH settings

A. Adding system variables Goroot: The first thing to do when you install Go is to set up goroot. For example, my go is installed in the C:\Go directory, you want to set goroot = C:\Go

B. Modify the environment variable path: Add%goroot%\bin to the environment variable path, so that you can run the%goroot%\bin directory program directly in the DOS command mode, such as: Go.exe Godoc.exe

C. Add system variable Gopath:gopath is an important variable to set the package load path. You can set multiple paths, separated by semicolons (;).

For example my gopath = D:\data\golang\letsgo;d:\data\golang;d:\data\golang\beego;d:\data\golang\beeweb;

I import a non-existent xxx bag

The following error is reported (this shows Gopath's important role in package):

Note: The source code of the package to be loaded must be placed in the SRC directory under the Gopath path, or the package will not be loaded

2. Go get download Open source system

Generally open source projects have a variety of dependencies, one Fock too troublesome. Try the go get command.

Below I use go get to get an open source blogging system (Github.com/lisijie/goblog) on GitHub:

1. Set the project path to Gopath (put in front of Gopath, go get to download the code into the first project directory inside the Gopath)

such as: I put the downloaded blog system to the D:\data\golang\goblog directory, then Gopath = D:\data\golang\goblog;d:\data\golang\letsgo;d:\data\golang;d:\data \golang\beego;d:\data\golang\beeweb;

Note: If a git shell is turned on, it is recommended to restart the Git shell, otherwise the Gopath setting is not in effect ...

2. Run go get github.com/lisijie/goblog under git shell for a few minutes ...

3. Go to the D:\data\golang\goblog directory to see

Related Article

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.