当前位置:网站首页>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
}
边栏推荐
- C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
- Converts a timestamp to a time in the specified format
- shardingsphere动态数据源
- Separable bonds and convertible bonds
- Recursive use and multi-dimensional array object to one-dimensional array object
- 编译文件时报错:错误: 编码GBK的不可映射字符
- 如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
- Mongodb installation & Deployment
- MongoDB安装 & 部署
- 动态规划:最长公共子串和最长公共子序列
猜你喜欢

Hutool动态添加定时任务

递归:深度优先搜索

Web session management security issues

Numpy warning visibledeprecationwarning: creating an ndarray from ragged needed sequences

npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。

Unity3d RPG implementation (medium)

简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息
![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
![[MySQL] the difference between left join, right join and join](/img/d4/8684cd59cd1bd77e70bd4d7c7074c3.jpg)
[MySQL] the difference between left join, right join and join

Download and install captura and configure ffmpeg in captura
随机推荐
Captura下载安装及在Captura配置FFmpeg
leetcode:动态规划模板
递归:深度优先搜索
Table structure of Navicat export database
Pat class B "1104 forever" DFS optimization idea
Download and install node, NPM and yarn
MongoDB簡介
C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
Elsevier latex 提交文章 pdftex.def Error: File `thumbnails/cas-email.jpeg‘ not found: using draf
用Three.js做一个简单的3D场景
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
Dynamic programming: longest common substring and longest common subsequence
Some preliminary preparations for QQ applet development: make an appointment for a development account, download and install developer tools, and create QQ applet
float与0比较
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
C语言HashTable/HashSet库汇总
@Accessors annotation function specifies that the prefix follows the hump naming
Makefile demo
递归:一维链表和数组
Téléchargement et installation du client Filezilla