当前位置:网站首页>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
}
边栏推荐
- [MySQL] the difference between left join, right join and join
- Limit of one question per day
- Convert binary stream to byte array
- FileZilla client download and installation
- Table structure of Navicat export database
- IPv6过渡技术-6to4手工隧道配置实验--尚文网络奎哥
- 错误 C2694 “void Logger::log(nvinfer1::ILogger::Severity,const char *)”: 重写虚函数的限制性异常规范比基类虚成员函数
- Web session management security issues
- Unity3d RPG implementation (medium)
- Web会话管理安全问题
猜你喜欢
Pytoch configuration
leetcode:动态规划模板
softmax的近似之NCE详解
小程序获取用户头像和昵称
MongoDB简介
Applet get user avatar and nickname
Don't use the new Dede collection without the updated Dede plug-in
Use three JS make a simple 3D scene
MongoDB簡介
IPv6 transition technology-6to4 manual tunnel configuration experiment -- Kuige of Shangwen network
随机推荐
MongoDB简介
Open Visual Studio 2010 hangs when opening a SQL file sql file
Tidal characteristics of the Bohai Sea and the Yellow Sea
com. fasterxml. jackson. databind. Exc.invalidformatexception problem
简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息
leetcode:动态规划模板
Application of derivative in daily question
CEPH Shangwen network xUP Nange that releases the power of data
Simple wechat applet development page Jump, data binding, obtaining user information, obtaining user location information
用Three.js做一個簡單的3D場景
用Three.js做一个简单的3D场景
递归:深度优先搜索
Ffmpeg recording screen and screenshot
MongoDB复制集【主从复制】
递归:快速排序,归并排序和堆排序
Lvgl usage experience
Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf
Dynamic programming: longest common substring and longest common subsequence
Basic operations of mongodb [add, delete, modify, query]
Hi3536C V100R001C02SPC040 交叉编译器安装