当前位置: 首页 > news >正文

go常用命令

创建一个module(逻辑概念)
#The go mod init command initializes and writes a new go.mod file in the current directory, in effect creating
#a new module rooted at the current directory.
#specify a module path that serves as the module’s name.
go mod initclone一个项目之后,不要使用go get去下载依赖(因为会默认下载最新版本),使用go mod tidy会下载go.mod文件中的指定版本
#go mod tidy ensures that the go.mod file matches the source code in the module.
#It adds any missing module requirements necessary to build the current module’s packages and dependencies,
#and it removes requirements on modules that don’t provide any relevant packages.
#It also adds any missing entries to go.sum and removes unnecessary entries.
#增加丢失的module依赖,移除没有被使用的module依赖(项目中没有使用该module依赖提供的任何包)
go mod tidy#You can check to see if there are newer versions of dependencies you’re already using in your current module.
go list -m -u allgo clean -cache#清除编译产生的缓存
go clean -modcache#清除下载的module依赖#compiles and installs the packages
#Executables(main packages)被安装到GOBIN目录下(默认是$GOPATH/bin).
#Non-executable packages are built and cached but not installed.
#main packages are built into executables and non-main packages are built into .a files.
go install package_path
go install golang.org/x/tools/gopls#安装当前module指定的版本go help clean,modules
go env# 查看配置信息
go env -w GOPROXY=https://goproxy.cn,direct#设置module proxy server为国内的,提高下载速度
#将同属于一个package的源文件编译为目标文件.o或者是package archive(packagefile).a文件
go tool compile -d help#go文件,没有参数,module path
go build -v -o demo.exe demo_pro
go build -gcflags -help
增加,移除,升级,降级某个module依赖,同时也会更新go.mod文件
#In Go 1.18, go get will no longer build and install packages.
#It will only be used to add, update, or remove dependencies in go.mod.go get package_path/module_path
参数:某个module或者某个module的一个package
参数为package_path时,go get会下载/更新提供这个包的module(更新就是升级到最新版本)
#If a package argument is specified, go get updates the module that provides the package.
#If an argument names a module but not a package(for example, the module golang.org/x/net has no package in its root
#directory), go get will update the module.
-u:升级command line上的package所依赖的module
#The -u flag tells go get to upgrade modules providing packages imported directly or indirectly by packages named
#on the command line.#升级/降级module依赖
go get golang.org/x/net#Upgrade a specific module.
go get golang.org/x/text@v0.3.2#Upgrade or downgrade to a specific version of a module.#移除这个module依赖,并且将依赖它的其他module依赖降级到不再依赖它
#Remove a dependency on a module and downgrade modules that require it to versions that don't require it.
go get golang.org/x/text@none

https://github.com/golang/go/issues/46912
https://pkg.go.dev/cmd@go1.22.3
https://pkg.go.dev/cmd/compile@go1.22.3
https://pkg.go.dev/cmd/go
https://stackoverflow.com/questions/69465514/what-is-the-difference-between-compile-and-build-in-go
https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/cmd/compile/;bpv=0

http://www.lryc.cn/news/361379.html

相关文章:

  • 【中年危机】程序猿自救指南
  • vueRouter路由总结
  • 算法工程师需要学习C++的哪些知识?
  • CTF网络安全大赛简单的web抓包题目:HEADache
  • Qt Creator创建Python界面工程并打包为可执行exe文件
  • 基于单片机的步进电机控制系统的研究
  • BioPorto胰高血糖素样肽-1抗体(GLP-1)
  • Go 语言字符串及 strings 和 strconv 包
  • 政府窗口服务第三方评估报告如何写
  • 若依前后端分离Spring Security新增手机号登录
  • Oracle操作扩可变字符长度交易影响分析-较小
  • 全栈工程师需要具备哪些技能?
  • 用java实现客服聊天+网络爬虫下载音乐(java网络编程,io,多线程)
  • 基于springboot+vue的医院信息管理系统
  • 乡村振兴与农业科技创新:加大农业科技研发投入,推动农业科技创新,促进农业现代化和美丽乡村建设
  • Java 雪花算法:分布式唯一ID生成的魔法秘籍
  • mybatis配置环境流程
  • UE5增强输入系统入门
  • Python 语法好乱:深度解析与应对策略
  • 移动端框架:加速移动应用开发与提升跨平台兼容性
  • Linux systemctl:掌握软件启动和关闭的利器
  • Jmeter干货分享:当你的Log viewer不显示日志时,可能是引入的Jar包冲突导致
  • 网络编程TCP
  • C++中的迭代器
  • 8.1 Go 包的概念与使用
  • 第一篇【传奇开心果系列】AI工业应用经典算法和Python示例:基于AI的智能制造技术经典算法与Python实践
  • Mathtype插入编号的高级格式会重置之前的简单格式的问题
  • 弘君资本:存储芯片概念强势,西测测试三连板,佰维存储涨超10%
  • 【机器学习】逻辑回归:原理、应用与实践
  • C++:list模拟实现