zoukankan      html  css  js  c++  java
  • go 环境搭建

    1,下载

    Golang官网下载地址:https://golang.google.cn/dl/

    2,解压到指定目录

    3,运行go 

    获取环境变量修改方法

    go help env
    usage: go env [-json] [-u] [-w] [var ...]
    
    Env prints Go environment information.
    
    By default env prints information as a shell script
    (on Windows, a batch file). If one or more variable
    names is given as arguments, env prints the value of
    each named variable on its own line.
    
    The -json flag prints the environment in JSON format
    instead of as a shell script.
    
    The -u flag requires one or more arguments and unsets
    the default setting for the named environment variables,
    if one has been set with 'go env -w'.
    
    The -w flag requires one or more arguments of the
    form NAME=VALUE and changes the default settings
    of the named environment variables to the given values.
    
    For more about environment variables, see 'go help environment'.
    

    windows现在环境变量

    C:UsersAdministrator>go env
    set GO111MODULE=on
    set GOARCH=amd64
    set GOBIN=
    set GOCACHE=C:UsersAdministratorAppDataLocalgo-build
    set GOENV=C:UsersAdministratorAppDataRoaminggoenv
    set GOEXE=.exe
    set GOFLAGS=
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOINSECURE=
    set GONOPROXY=
    set GONOSUMDB=
    set GOOS=windows
    set GOPATH=C:Go
    etworkpkg;
    set GOPRIVATE=
    set GOPROXY=https://goproxy.io,direct
    set GOROOT=c:go
    set GOSUMDB=sum.golang.org
    set GOTMPDIR=
    set GOTOOLDIR=c:gopkg	oolwindows_amd64
    set GCCGO=gccgo
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set GOMOD=NUL
    set CGO_CFLAGS=-g -O2
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:UsersADMINI~1AppDataLocalTempgo-build644129466=/tmp/go-build -gno-record-gcc-switches
    
    C:UsersAdministrator>

    linux 现在环境变量

    root@ubuntu:~# go env
    GO111MODULE="on"
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/root/.cache/go-build"
    GOENV="/root/.config/go/env"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOINSECURE=""
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="linux"
    GOPATH="/root/go"
    GOPRIVATE=""
    GOPROXY="https://goproxy.cn/"
    GOROOT="/home/goenv/go"
    GOSUMDB="sum.golang.org"
    GOTMPDIR=""
    GOTOOLDIR="/home/goenv/go/pkg/tool/linux_amd64"
    GCCGO="gccgo"
    AR="ar"
    CC="gcc"
    CXX="g++"
    CGO_ENABLED="1"
    GOMOD="/dev/null"
    CGO_CFLAGS="-g -O2"
    CGO_CPPFLAGS=""
    CGO_CXXFLAGS="-g -O2"
    CGO_FFLAGS="-g -O2"
    CGO_LDFLAGS="-g -O2"
    PKG_CONFIG="pkg-config"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build869956040=/tmp/go-build -gno-record-gcc-switches"
    root@ubuntu:~# 
    

     设置/etc/profile环境变量

    设置GOPATH环境变量
    
    修改/etc/profile系统环境变量文件,写入GOPATH信息以及go sdk路径
    #for go env
    
    export GOROOT=/home/goenv/go
    export PATH=$PATH:$GOROOT/bin
    
    读取/etc/profile,立即生效
    
    source /etc/profile     #读取环境变量
    

      

     修改方法

    go env -w GOPROXY=https://goproxy.cn/
    go env -w GO111MODULE=on

      

    想在linux 同时设置 x64,x86的环境失败了.

    GOCACHE="/root/.cache/go-build"
    GOENV="/root/.config/go/env"

    GOROOT="/home/goenv/go"
    会同时修改.只有用2台机器来配置环境变量

    安装mingw ,gcc

    安装mingw,想用g++gcc编译器。
    
    网上很多教程都是指引下载安装器的,但是下载后在线安装时却都出现下载的错误,所以无法安装成功。
    
    参考mingw贴吧:https://tieba.baidu.com/p/5487544851?red_tag=1967781305
    
    可以到页面:https://sourceforge.net/projects/mingw-w64/files/?source=navbar 下载离线安装包
    

      

  • 相关阅读:
    贰、js的基础(二)类型转换
    贰、js的基础(一)
    ajax的异步请求小结
    壹、js的概述
    sass的用法小结(四)进阶篇
    sass的用法小结(三)
    sass的用法小结(二)
    sass的用法小结(一)
    H5页面在线制作工具搜集
    H5教程:移动页面性能优化
  • 原文地址:https://www.cnblogs.com/bleachli/p/14812698.html
Copyright © 2011-2022 走看看