当前位置:网站首页>Go language - use of packages
Go language - use of packages
2022-06-23 05:27:00 【Crying while learning】
GO In language , Packages are actually directories one by one
- be-all go Clouds cannot be placed under the same bag , Subcontracting management is usually required ;
- Under the same package , be-all go file package Statement to be consistent ;
- main Package only the main function can be used ;
- Packages can be nested , But you can't loop and nest .
Usually the directory structure can be as follows :
gopath/project_name/package
go working space / project / package
Import package
// Import a single package
import "package_name"
// Import multiple packages
import (
"package_name1"
"package_name2"
)Absolute path : from goroot perhaps gopath In the directory of src Look for the package in the directory
Relative paths : Relative to current go The location of the file
Point operation
import (
. "fmt"
)Add... Before the imported package . You can call functions under the package without writing the package name .
As originally fmt.Println, Ahead fmt. It can be omitted .
Starting point name
Alias operation , You can use aliases instead of package names .
import (
p1 "package1"
p2 "package2"
)_ operation
If you import a package , Not to execute the functions in the package , Just to execute the init() function , You can use _ operation .
import (
_ "package1"
)边栏推荐
- 如何进行探索性数据分析
- JDBC入门学习(四)之Druid连接池的使用
- Qt QWidget嵌套相对位置获取 (qt 画线 嵌套)
- How to conduct exploratory data analysis
- Un processus GC complet pour le principe JVM
- STM32cube CMSIS_V2 freeRTOS Queue 队列使用
- 左侧固定,右侧自适应 三种实现办法(Flex,float + BFC ,float-margin-left)
- CF【1700D】D. River Locks(dp、二分、数学)
- 面对新的挑战,成为更好的自己--进击的技术er
- 架构师之路,从「存储选型」起步
猜你喜欢

Image noise reduction denoise AI

Introduction and use of precise ephemeris

Onnxoptimizer, onnxsim usage records

MCS:连续随机变量——Student’s t分布

(IntelliJ) plug in background image plus

九九乘法表.bat

BGP second test

How to conduct exploratory data analysis

Zygote进程

MCS: continuous random variable chi square distribution
随机推荐
VMware network connection error unit network service not found
Economic development is driven by new technology
Raspberry pie network remote access
关于DOS/DDOS攻击和防御
PHP move_ uploaded_ File failed to upload mobile pictures
Event log keyword: eventlogtags logtags
Mongodb sharding principle
MCS: continuous random variable chi square distribution
Three tier architecture experiment
[microservices | Nacos] Nacos realizes data isolation of multi environment and multi tenant
Qt QWidget嵌套相对位置获取 (qt 画线 嵌套)
JDBC入门学习(二)之封装工具类
Sift特征点提取
Master shell, one article is enough!
Un processus GC complet pour le principe JVM
[leetcode] longest increasing subsequence problem and its application
pygame音乐相关的功能实现
bat中获取bat命令结果
弱者易怒如虎,强者平静如水,真正厉害的人早已戒掉了情绪
LeetCode 797:所有可能的路径