当前位置:网站首页>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
}
边栏推荐
- Pytorch multi card distributed training distributeddataparallel usage
- 释放数据力量的Ceph-尚文网络xUP楠哥
- Download and install node, NPM and yarn
- Bid farewell to artificial mental retardation: Mengzi open source project team received RMB 100 million financing to help NLP develop
- Web session management security issues
- [combinatorics] brief introduction to generating function (definition of generating function | Newton binomial coefficient | commonly used generating function | correlation with constant | correlation
- js中#号的作用
- C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
- [mathematical logic] propositional logic (propositional logic reasoning | formal structure of reasoning | inference law | additional law | simplification law | hypothetical reasoning | refusal | disju
- Nce detail of softmax approximation
猜你喜欢
Application of derivative in daily question
Mongodb replication set [master-slave replication]
Summary of electromagnetic spectrum
渤、黄海的潮汐特征
umi 路由拦截(简单粗暴)
Pytorch multi card distributed training distributeddataparallel usage
Web会话管理安全问题
[embedded module] OLED display module
UMI route interception (simple and rough)
Learning notes of C programming [compiled by Mr. Tan Haoqiang] (Chapter III sequence programming) 04 C sentence
随机推荐
Without sxid, suid & sgid will be in danger- Shangwen network xUP Nange
Convert binary stream to byte array
监听对象中值变化及访问
释放数据力量的Ceph-尚文网络xUP楠哥
使用InputFilter限制EditText时踩坑及解决方案
Elsevier latex 提交文章 pdftex.def Error: File `thumbnails/cas-email.jpeg‘ not found: using draf
简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息
Compare float with 0
MongoDB复制集【主从复制】
Solve high and send system Currenttimemillis Caton
@Accessors annotation function specifies that the prefix follows the hump naming
npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
FileZilla client download and installation
Application of derivative in daily question
leetcode:动态规划模板
Docker install and start MySQL service
【学习笔记】seckill-秒杀项目--(11)项目总结
Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
Ffmpeg recording screen and screenshot
UMI route interception (simple and rough)