您的位置 首页 golang

搭建Go语言环境配置

Windows在环境变量中填入

GOPATH这一项在用户变量填入,其余在系统变量填入

Linux中配置

export GOPATH=/home/gocode

#项目代码目录

GOPATH=E:\golang\go

#启用Go Modules功能

GO111MODULE=on

#配置GOPROXY环境(国内环境用到)

GOPROXY=

#关闭包安全校验

GOSUMDB=off

#设置私有仓库,多个用逗号相隔

GOPRIVATE=git.demo1.cc/*,git.demo2.cc/*

#git登录提示

GIT_TERMINAL_PROMPT=1

windows配置

查看配置

go env

module使用

初始化:

go mod init

更新:

go mod tidy

范例:

 package main

import (
	"fmt"
	"io"
	"os"
	"github.com/google/uuid"
)

func main() {
	var id string
	id = uuid.New().String()
	s := fmt.Sprintf("this is uuid: %s", id)
	io.WriteString(os.Stdout, s)
}
  

这里需要执行,go get github.com/google/uuid

文章来源:智云一二三科技

文章标题:搭建Go语言环境配置

文章地址:https://www.zhihuclub.com/88471.shtml

关于作者: 智云科技

热门文章

网站地图