go_common

command module
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 3 Imported by: 0

README

Golang 公共项目

Golang开发环境安装

安装

此处 下载安装

环境变量配置

Windows

在我的电脑->属性->高级->环境变量->系统变量中添加以下环境变量:

GOROOT=C:\go
GOPATH=%USERPROFILE%\go
GO111MODULE=auto
GOPROXY=https://goproxy.cn

PATH环境变量末尾添加 %GOROOT%\bin

MAC OS X

sudo vi ~/.bash_profile

修改以下项目

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH="${GOROOT}/bin:${PATH}"
export GO111MODULE=auto
export GOPROXY=https://goproxy.cn

source .bash_profile

更新配置

与Java、Python、NodeJS、PHP等均不同,只是开发环境需要安装用于代码编译,生产环境直接运行项目编译好的可执行文件即可,无需安装任何类似JRE、Python、v8、PHP的虚拟机或运行时环境!

执行以下操作前请理解并确认:

  1. GOPATH 环境变量已配置,例如配置到用户目录下的go目录
  2. GOPATH 目录是用于存放golang项目和其相关依赖的目录,所有golang项目代码都应该位于GOPATH目录中的src子目录下的包括代码托管地址、组织名、项目名在内的多级子目录下
  3. GO111MODULE 环境变量指定golang管理依赖包的模式,auto,则当项目中有go.mod文件时,采用go mod模式
  4. GOPROXY设置golang获取依赖包的代理,此处设置七牛云官方提供的代理

获取项目

GO MOD

golang已经是1.14或更新版本,强烈建议项目都采用go mod方式进行依赖包管理

go mod方式下,不再使用GOPATH src目录,自有项目也不再强制要求放置于全局或额外GOPATH的src子目录结构中,go mod版本号来源于git tag

但go install构建结果依然放在全局GOPATH的bin目录中,且go mod的带版本依赖包也放置在全局GOPATH的pkg目录中

go mod项目初始化,建议mod名称为代码仓库全路径,可保持在所有项目中引用路径一致,如

go mod init git.wanpinghui.com/WPH/go_common

获取

获取非https的私有仓库,需要如下处理

执行下列命令临时关闭goproxy代理

export GOPROXY=

获取包,如果在go mod模式项目中执行,会自动将go get获取的依赖加入go.mod文件

go get -v -insecure -d git.wanpinghui.com/WPH/go_common

参数:-v 显示详情,-insecure 非https版本仓库路径,-d 仅获取,不编译安装到GOPATH

重启控制台,或临时设置goproxy代理,使goproxy代理

export GOPROXY=https://goproxy.cn

go mod常用命令

获取和清理依赖包

go mod tidy

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
wph
github.com/axgle/mahonia
This package is a character-set conversion library for Go.
This package is a character-set conversion library for Go.
gophone
* Copyright (c) 2015, zheng-ji.info *
* Copyright (c) 2015, zheng-ji.info *
jws
mq
yxsdk
* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.
* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL