Development environment Configuration and multi-workspace configuration for Windows go

Source: Internet
Author: User

The main contents of this article are as follows:

    1. Download and install Go
    2. Configure multiple workspaces, the first to put third-party packages by default, and other put project codes
    3. Package Manager godep Installation and use
    4. Some pits during installation (wall)
    5. Use go in Vscode
1. Download and install go

Download the website or golang China download
Default installation to C:\GO , using go version view version:

The current version is: 1.10

2. Create a new workspace

    1. Create a new two folder
      DEPSOURCE\SRC: Place the source of the go dependency package
      GOCODING\SRC: The code directory where you put yourself or test your project
    2. Configure the path of the two folders and the corresponding bin in order to the environment variable GOPATH , create a new system variable Gopath, and then the value is: the C:\GoWorks\DepSource;C:\GoWorks\GoCoding;C:\GoWorks\DepSource\bin;C:\GoWorks\GoCoding\bin; drive letter should be modified by yourself
    3. will be %GOPATH% configured in a system variable path

      ------------
      At home the computer reconfigured, go installed on the D-disk, Gopath configuration to the E-drive, as shown in
    • Folder
    • Environment variables
3. Install Package Manager godep3.1 Downloads
    1. Get GODEP Package:- go get -v github.com/tools/godep v Show log output-u update to latest version
    2. Check to see if there is a godep.exe after the download is complete C:\GoWorks\DepSource\bin\godep.exe and the installation is successful
    3. Godeps\Godeps.jsonrestore dependent packages based on configuration

      If you have one in your project Godeps\Godeps.json , you can use the godep get dependent packages that you install

3.2 Generating a dependency profile for a go project
    1. Creating a new Go Project OneGo (gocoding\src\onego), create a main.go file, and introduce a test package and open cmd to the current path

      package mainimport (    "github.com/yimogit/gotest")func main() {    test.HelloWord()}
    2. To install a test package:go get -v github.com/yimogit/gotest
    3. To build a dependent configuration:godep save
    4. Success, if successful, you see a folder created under the OneGo folder Godeps,vendor
    5. Run: go run main.go , the console outputHello Word
    6. The package EXE usesgo build -o test.exe

4. When installing the Go Framework gin there will be some dependencies that require manual installation of some packages

Start the godep save build dependency configuration file, the first time you use this command will report a bunch github.com/*/* of missing package errors, installation can be error diagram list
When godep: Package (golang.org/x/sys/unix) not found it comes to downloading a package from golang.org (if you can count on me not to say), you need to change the path from github to download (wall, then go on GitHub to put a copy ~)
Specific solutions are:
Create a new folder in the previously set Gopath path (C:\GOWORKS\DEPSOURCE\SRC) golang.org\x , and then clone or download the SYS package
Full command (self-modifying path):git clone https://github.com/golang/sys.git C:\GoWorks\DepSource\src\golang.org\x\sys
In the event of a package download failure in the installation process, you can download it directly to the Github.com folder using the Clone command and then execute go get github.com/x/x it to install the

5. Use the dependent packages that need to be installed in Vscode

Installation extension: Vscode-go
Installation dependencies: You can configure the Go development environment in Vscode by following the Vscode prompts or by installing these dependent packages directly.

go get -u -v github.com/nsf/gocode      go get -u -v github.com/rogpeppe/godef      go get -u -v github.com/golang/lint/golint   go get -u -v github.com/lukehoban/go-find-references   go get -u -v github.com/lukehoban/go-outline        go get -u -v sourcegraph.com/sqs/goreturns          go get -u -v github.com/tpng/gopkgs     go get -u -v github.com/newhook/go-symbols      go get -u -v github.com/peterh/liner go get -u -v github.com/derekparker/delve/cmd/dlv   

Development environment Configuration and multi-workspace configuration for Windows go

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.