当前位置:网站首页>golang xxx. Go code template
golang xxx. Go code template
2022-07-03 03:39:00 【sky527759】
package aaaexample
// import The order
// import (
// // golang Standard library
// "xxx"
//
// // Package of this project
// "xxx"
//
// // Company internal package
// "xxx"
//
// // External third party packages , Such as github Open source package on
// "xxx"
// )
// Export and non export are written separately , Package level constants and variables are const and var in , Single can be used directly
const (
Zero int = 0 // Zero Is an example of exporting constants
IsZero bool = false // IsZero Is an example of exporting constants
zero int = 0 // zero Is an example of an unexported constant
hasZero bool = false // hasZero Is an example of an unexported constant
)
var (
ZeroVar int = 0 // ZeroVar Is an example of exporting variables
IsZeroVar bool = false // IsZeroVar Is an example of exporting variables
zeroVar int = 0 // zeroVar Is an example of an unexported variable
isZeroVar bool = false // isZeroVar Is an example of an unexported variable
)
type (
// ZeroFun Is an example of exporting function type declarations
ZeroFun func() int
// zeroFun Is an example of an unexported function type declaration
zeroFun func() int
)
type (
// ZeroInterface Is exported, not empty interface An example of an interface declaration
ZeroInterface interface {
Write(int, int) error // Write ....
Read(int, int) error // Read ....
}
// zeroInterface Is not exported, not empty interface An example of an interface declaration
zeroInterface interface {
write(int, int) error // write ....
read(int, int) error // read ....
}
)
/* init yes init An example of , init Can only operate the contents of this package , Not directly / Indirect call / Reference external package content */
func init() {
isZeroVar = (Zero == 0)
}
// Example Is an example of a structure definition , The comments on the structure are written here
type Example struct {
ExampleField1 int // Example field 1, The comments on the field are written here
ExampleField2 *int // Example field 2
}
/* IsZero Is an example of writing a structure receiver function , return false Return value : @1: false NOTE: This is an example of a structure receiver function , Notes on the use of functions can be written here */
func (e Example) HasZero() bool {
return hasZero
}
/* IsZero Is an example of writing pointer receiver functions , return false Return value : @1: false NOTE: This is an example of a pointer receiver function , Notes on the use of functions can be written here */
func (e *Example) IsZero() bool {
return IsZero
}
// The format of function annotation is as follows : Parameters : With tab operator , Other spaces are spaces
// bug An example of the list is as follows bug The name in parentheses after is familiar with this bug 's name , The spaces that appear are all space characters ,
// ( The person's name ) Followed by this go This... Appears in the file bug Method name of , Finally, we should bug Description of ,
// bug The list should be in the first position below the package name
/* AAAExampleAdd Is a function example , Realize two numbers a and b Add up Parameters : @a: Augend a; @b: Augend b Return value : @1: Sum of two numbers ; @2: Function error code BUG( Chen Xiaoyang ) AAAExampleAdd This is a bug Example of , When a and b Add more than int When the range can be expressed , It's going to happen “ overflow ” BUG( Chen Xiaoyang ) AAAExampleAdd This is a bug Example of 2, When a and b Add more than int When the range can be expressed , It's going to happen “ overflow ” NOTE: This is a function example , Notes on the use of functions can be written here */
func AAAExampleAdd(a, b int) (int, error) {
return a + b, nil
}
/* AAAExampleSub Is a function example , Realize two numbers a reduce b Parameters : @a: Subtract a; @b: minuend b Return value : @1: The difference between the two ; @2: Function error code BUG( Chen Xiaoyang ) AAAExampleAdd This is a bug Example of , When ................... NOTE: This is a function example , Notes on the use of functions can be written here */
func AAAExampleSub(a, b int) (int, error) {
return a - b, nil
}
边栏推荐
- npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
- Open Visual Studio 2010 hangs when opening a SQL file sql file
- Convert binary stream to byte array
- 动态规划:最长回文子串和子序列
- C语言HashTable/HashSet库汇总
- 动态规划:最长公共子串和最长公共子序列
- 用Three.js做一个简单的3D场景
- float与0比较
- @The difference between Autowired, @qualifier, @resource
- Basic operations of mongodb [add, delete, modify, query]
猜你喜欢
![C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output](/img/38/9c460fc58b62609dd02e7c61207ae6.jpg)
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output

Ffmpeg download and installation tutorial and introduction

Message queue addition failure

Mysql Mac版下载安装教程

Application of derivative in daily question

Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf

MongoDB复制集【主从复制】

Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi

TCP/IP模型中的重磅嘉宾TCP--尚文网络奎哥

FileZilla Client下載安裝
随机推荐
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
redis高级应用【密码防护、数据持久化、主从同步、哨兵模式、事务】【暂未完成(半成品)】
sigaction的使用
900W+ 数据,从 17s 到 300ms,如何操作
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
[mathematical logic] normal form (conjunctive normal form | disjunctive normal form | major item | minor item | maximal item | minor item | principal conjunctive normal form | principal disjunctive no
Téléchargement et installation du client Filezilla
The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post
Ffmpeg recording screen and screenshot
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
Pytorch multi card distributed training distributeddataparallel usage
Open Visual Studio 2010 hangs when opening a SQL file sql file
ffmpeg下载安装教程及介绍
Makefile demo
docker安装及启动mysql服务
QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
com. fasterxml. jackson. databind. Exc.invalidformatexception problem
[learning notes] seckill - seckill project - (11) project summary
Solve high and send system Currenttimemillis Caton