当前位置:网站首页>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
}
边栏推荐
- umi 路由拦截(简单粗暴)
- Learning notes of C programming [compiled by Mr. Tan Haoqiang] (Chapter III sequence programming) 04 C sentence
- TCP, the heavyweight guest in tcp/ip model -- Kuige of Shangwen network
- [set theory] partial order relation (partial order relation definition | partial order set definition | greater than or equal to relation | less than or equal to relation | integer division relation |
- 释放数据力量的Ceph-尚文网络xUP楠哥
- Filter
- Pytorch multi card distributed training distributeddataparallel usage
- 监听对象中值变化及访问
- node,npm以及yarn下载安装
- Pat class B common function Usage Summary
猜你喜欢

Message queue addition failure

ffmpeg之 一张/多张图片合成视频

QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序

IPv6过渡技术-6to4手工隧道配置实验--尚文网络奎哥

Vs 2019 configuration tensorrt

Mysql Mac版下载安装教程

Recursion: quick sort, merge sort and heap sort

900W+ 数据,从 17s 到 300ms,如何操作

用Three.js做一个简单的3D场景

TCP, the heavyweight guest in tcp/ip model -- Kuige of Shangwen network
随机推荐
Docker install and start MySQL service
Ansible简介【暂未完成(半成品)】
ffmpeg下载安装教程及介绍
Advanced redis applications [password protection, data persistence, master-slave synchronization, sentinel mode, transactions] [not completed yet (semi-finished products)]
403 error displayed when vs cloning
Download and install node, NPM and yarn
动态规划:最长回文子串和子序列
Téléchargement et installation du client Filezilla
Basic operations of mongodb [add, delete, modify, query]
Ansible introduction [unfinished (semi-finished products)]
leetcode:动态规划模板
Yolov5 project based on QT
[learning notes] seckill - seckill project - (11) project summary
UMI route interception (simple and rough)
Shardingsphere dynamic data source
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
LVGL使用心得
numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
The series of hyperbolic function in daily problem
Error in compiled file: error: unmapped character encoding GBK