惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 海风吹

Chrome浏览器界面截图 linux文件锁flock【转】 go的临时对象池--sync.Pool golang 小知识-持续更新中 【转】Go Channels Parquet存储格式 - 论文翻译【转】 预装的Office2016,文件图标表显示以及新建失败问题解决 方法 Gamma编码及Delta编码概述 时序数据库技术体系 – InfluxDB 多维查询之倒排索引 时序数据库技术体系 – InfluxDB TSM存储引擎之TSMFile 时间序列数据的存储和计算 - 开源时序数据库解析 时序数据库技术体系-时序数据存储模型设计 时序数据库-为万物互联插上一双翅膀 JMS和ActiveMQ的关系 JMS(Java消息服务)入门教程 Influxdb时序数据库阅读笔记 代码只是事业的 5%,程序员创业注意事项 - 海风吹 golang 之 channel golang中context包学习
Golang文件名命名规则
海风吹 · 2018-05-17 · via 博客园 - 海风吹

在golang源代码中,经常看到各种文件名,比如: bolt_windows.go。

下面对文件名命令规则的说明:

1、平台区分

文件名_平台。

例: file_windows.go, file_unix.go

可选为:windows, unix, posix, plan9, darwin, bsd, linux, freebsd, nacl, netbsd, openbsd, solaris, dragonfly, bsd, notbsd, android,stubs

2、测试单元

文件名_test.go或者 文件名_平台_test.go。

例: path_test.go,  path_windows_test.go

3、版本区分(猜测)

文件名_版本号等。

例:trap_windows_1.4.go

4、CPU类型区分, 汇编用的多

文件名_(平台:可选)_CPU类型.

例:vdso_linux_amd64.go

可选:amd64, none, 386, arm, arm64, mips64, s390,mips64x,ppc64x, nonppc64x, s390x, x86,amd64p32

-------------------------------------------------------------------------------------------------

1、golang的命名需要使用驼峰命名法,且不能出现下划线

2、golang中根据首字母的大小写来确定可以访问的权限。无论是方法名、常量、变量名还是结构体的名称,如果首字母大写,则可以被其他的包访问;如果首字母小写,则只能在本包中使用

  可以简单的理解成,首字母大写是公有的,首字母小写是私有的

3、结构体中属性名的大写

如果属性名小写则在数据解析(如json解析,或将结构体作为请求或访问参数)时无法解析

 --------------------------------------------------------------------------------------------------------

注意点一、

go build 的时候会选择性地编译以系统名结尾的文件(linux、darwin、windows、freebsd)。例如Linux(Unix)系统下编译只会选择array_linux.go文件,其它系统命名后缀文件全部忽略。

 注意点二、

在xxx.go文件的文件头上添加 // + build !windows (tags),可以选择在windows系统下面不编译 

// +build !windows

package main

总结:golang跨平台没有java好用,但是跟c语言差不多,都得针对不同平台不同特性迭轮子