golang-Development Configuration

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

Environment variable Configuration



GOROOT = D:\ProgramDev\Go


GOROOT = D:\WorkSpace\goProjects


GOBIN = D:\WorkSpace\goProjects\bin


Path = D:\ProgramDev\Go\bin

Test environment variables

$ go envset GOARCH=amd64set GOBIN=D:\WorkSpace\goProjects\binset GOEXE=.exeset GOHOSTARCH=amd64set GOHOSTOS=windowsset GOOS=windowsset GOPATH=D:\WorkSpace\goProjectsset GORACE=set GOROOT=D:\ProgramDev\Goset GOTOOLDIR=D:\ProgramDev\Go\pkg\tool\windows_amd64set GCCGO=gccgoset CC=gccset GOGCCFLAGS=-m64 -mthreads -fmessage-length=0set CXX=g++set CGO_ENABLED=1set CGO_CFLAGS=-g -O2set CGO_CPPFLAGS=set CGO_CXXFLAGS=-g -O2set CGO_FFLAGS=-g -O2set CGO_LDFLAGS=-g -O2set PKG_CONFIG=pkg-config

Writing code

package mainimport (    "fmt")func main() {    fmt.Println("Hello World!")}

Run the program

$ go run hello.goHello World!



vim /home/vagrant/.profile# 添加export GOROOT=/usr/local/goexport GOPATH=/home/vagrant/workspace/goProjects/learn-go/export GOBIN=/home/vagrant/workspace/goProjects/learn-go/binexport PATH=$PATH:$GOROOT/bin:$GOBIN

Test environment variables

vagrant@debian:~$ go envGOARCH="amd64"GOBIN="/home/vagrant/workspace/goProjects/learn-go/bin"GOEXE=""GOHOSTARCH="amd64"GOHOSTOS="linux"GOOS="linux"GOPATH="/home/vagrant/workspace/goProjects/learn-go/"GORACE=""GOROOT="/usr/local/go"GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"GCCGO="gccgo"CC="gcc"GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build955111107=/tmp/go-build -gno-record-gcc-switches"CXX="g++"CGO_ENABLED="1"CGO_CFLAGS="-g -O2"CGO_CPPFLAGS=""CGO_CXXFLAGS="-g -O2"CGO_FFLAGS="-g -O2"CGO_LDFLAGS="-g -O2"PKG_CONFIG="pkg-config"

Run the program

vagrant@debian:~/workspace/goProjects/src/awesomeGo$ go run hello.go Hello World!
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.