当前位置:网站首页>Environmental preparation - Engineering Management
Environmental preparation - Engineering Management
2022-06-29 07:53:00 【qazw9600】
explain
- Project management is project management ,go The language provides workspace management , Source code management , The third party relies on specifications such as library management .
- go Is the engineering language , Not as free as college language , Some specifications have been made for project management .
work area (workspace) management
- go Language programming , It is not easy to create a directory as a working directory , Because it depends on file search and intermediate 、 Generation of target file , And the installation of executable files ,go There are certain specifications for the directory structure of the workspace and the designation of the workspace .
- Of course, if the project has only a single source file or multiple files, but the import package path is written to the absolute path, it can also be compiled , But this is not recommended .
View and set up
- go The default workspace will be set after the environment is installed , And create a default directory structure under this directory ,linux for ~/go/.
- go adopt GOPATH The environment variable sets the workspace path , It can be modified manually , However, you need to manually create these subdirectories after modification .
- see
go env GOPATH
- Set up
export $GOPAHT=/xxx/xxx
- Be careful :GOPATH You can set multiple , But if you set multiple paths , Need to set up GOBIN Environment variables to determine which directory the executable is placed in .
Directory structure
- The workspace contains 3 Subdirectory .
- src Catalog : Store project source code , A project is divided into a subdirectory , go get The downloaded third-party packages are also placed in this directory .
- pkg Catalog : Storage via go install Command to build the installed “.a” The archive .
- bin Catalog : And pkg Similar directory , Through go install After the command is installed , Save by Go Command source file generated executable file .
Develop and improve
- GOPATH The mechanism is primitive and simple , In the process of development, it shows some deficiencies , for example :
- The code must be in GOPATH The next path src Directory , Otherwise , Importing the package in the project will prompt that it cannot be found .
- Dependent packages need to be managed manually , No version number information .
- …
- The official management mechanism is also improving , Experienced GOPATH、go vendor, At present, the latest and mainstream official mechanism is go mod.
Source code and third-party dependency library management
- go Both source code and third-party dependency libraries are organized and managed in the form of source code packages .
Engineering example
- Create a project
- Early creation of a new project needs to be done in the workspace src Under the table of contents , But with go mod The mechanism does not need , Can be created in any directory .
- Create a project root directory , for example :example, Put the code in the root directory .
- Compile and install
- The compilation needs to be executed under the root directory of the project “go build” command ,go The compiler will automatically derive the dependencies , The compiled executable name is the project name .
- The installation needs to be executed in the same directory “go install”,go The compiler will place the generated file in the... Of the workspace bin and pkg Next .
- A single file program can also compile the file directly , as follows :
go build xxx.go
边栏推荐
- SQL Server 2008 publish and subscribe to SQL Server 2017 pit avoidance Guide
- Cartographer中的线程池操作
- Problem solving -- > online OJ (13)
- 1031 Hello World for U
- pycharm的虚拟环境如何共享到jupyter-lab
- 498. 对角线遍历(模拟)
- [量化投资系统]Django从数据库中实现筛选及分页
- Roblox剑九之剑二
- 【域渗透提权】CVE-2020-1472 NetLogon 权限提升漏洞
- Schnuka: 3D machine vision inspection system 3D vision inspection application industry
猜你喜欢

Blue Bridge Cup - minimum frame

Vulnhub's dc9 target

【深度之眼吴恩达第四期作业班】多元线性回归Linear Regression with multiple variables总结

1032 Sharing

【工控老马】西门子PLC s7-300SCL编程详解

Using cdockablepane to realize floating window in MFC

AI and the meta universe sparked a spark: human beings lost only shackles and gained all-round liberation

Roblox剑九之剑二

tf. count_ nonzero

搭建jenkins环境并自动关联打包好的工程jar进行自动发布
随机推荐
mysql 开启日志功能
AC自动机
Some examples.
Oracle batch insert data - insert ethnic data
多态中的向上和向下转型
MIPS instruction set and brief analysis
postman预处理/前置条件Pre-request
嵌入式产品防盗版
[industrial control old horse] detailed explanation of the design scheme of the running lamp control system based on Siemens S7-200PLC
SAP ui5 Beginner (I) Introduction
呕心沥血总结出来的MySQL常见错误以及解决方法(一)
Reasons why the ext.dic file configured in ES does not take effect
【深度之眼吴恩达第四期作业班】多元线性回归Linear Regression with multiple variables总结
【工控老马】PLC六路抢答器系统设计详解
498. diagonal traversal (simulation)
Compiling principle: the king's way
线段树以及使用
产品安全 - 小漏洞导致大问题
Kyushu cloud helps Inner Mongolia's "counting from the east to the west" project to drive the smart new ecology of the surveying and mapping industry
小白大战指针 (上)