go-fox-edge-common

command module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: GPL-3.0 Imports: 0 Imported by: 0

README

go-fox-edge-common

组件库的介绍

Fox-Edge的GO版本组件库

go编译器的安装

ubuntu20自带的版本,比较旧,go的编译器版本,至少使用1.22以及以上版本,所以下载go官网的版本

wget https://dl.google.com/go/go1.22.0.linux-arm64.tar.gz

tar -C /usr/local -xzf go1.22.0.linux-arm64.tar.gz

echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile
IDEA的调试

在IDEA中,可以通过安装go的插件,进行安装调试。但是,IDEA插件市场上的dlv调试器,最高只支持到1.18版本。

所以,它调试新版本的GO,将出现可能调试错误的信息:WARNING: undefined behavior - version of Delve is too old for Go version 1.22 (maximum supported version 1.18)

这时候,可以通过下列命令,使用你安装的GO,编译出一个当前GO版本的调试器dlv.exe

go install github.com/go-delve/delve/cmd/dlv@latest

echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profile

echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.profile
source ~/.profile

然后,你将GO目录下的dlv.exe复制出来,把IDEA目录下的dlv.exe替换掉,这时候调试工具的版本就匹配了。

IDEA的远程调试

在远程的LINUX环境中,安装delve

#在服务器上使用dlv引导你的程序,其中2345是IDEA上配置的远程debug端口,下面的前面的引导头,后面接你自己的代码程序命令
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec 
组件库的初始化
#go mod的初始化
#gitee仓库:https://gitee.com/fierce_wolf/go-fox-edge-common.git
go mod init gitee.com/fierce_wolf/go-fox-edge-common
组件库的提交

在git上提交代码后,go需要在git仓库打上版本号(v1.x.x格式)的tag,那么后面其他go工程就可以使用这个库了

# 在git提交代码后,再在git库上打上go需要的tag 版本标识
git tag v1.0.0
git push origin v1.0.0
组件库的引用

go默认的GOPROXY是https://proxy.golang.org非常的缓慢,可以切换为国内的镜像goproxy.cn来解决

#go默认的GOPROXY是https://proxy.golang.org非常的缓慢,可以切换为国内的镜像goproxy.cn来解决
go env -w GOPROXY=https://goproxy.cn,direct

#查询最新可用版本
go list -m -versions gitee.com/fierce_wolf/go-fox-edge-common

#可以使用该命令下载gitee上的仓库到本地计算机上
go list

#第三方库下载
go get -u github.com/satori/go.uuid
go get -u github.com/go-sql-driver/mysql

#可以本地测试自己的go工程代码
go run main.go

#也可以windows本地编译
go build -o main.exe
这个库是否臃肿

这个库的代码比较多,是否会比较臃肿呢?

回答:不会

原因:GO的编译器是自动根据各个GO文件中的import,进行依赖关系的自动分析的。

GO的编译器会自动分析代码的依赖关系,然后忽略掉你的业务代码实际上并未引用的业务代码。

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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