Skip to content

Commit

Permalink
Create go_codelayout.md
Browse files Browse the repository at this point in the history
add go code layout rule
  • Loading branch information
xixisese authored Nov 1, 2018
1 parent 0739064 commit b5def45
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions linkchain/go_codelayout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## 代码布局
```
//package
package context
//import
import (
//系统库
"fmt"
"math/rand"
"os"
"time"
//项目内部库
linchain/xx/
//第三方库
"github.com/spf13/pflag"
)
//const定义
const (
MaxActiveDialTasks = 16
)
//error定义
var (
ErrInvalidUnreadByte = errors.New("bufio: invalid use of UnreadByte")
ErrInvalidUnreadRune = errors.New("bufio: invalid use of UnreadRune")
)
//var定义
var (
blockIndexBucketName = []byte("blockheaderidx")
)
/*
error struct定义
*/
type PathError struct {
Op string
Path string
Err error
}
func (e *PathError) Error() string { return e.Op + " " + e.Path + ": " + e.Err.Error() }
/*
struct 1
*/
//struct定义
type Conn struct {
Name string
}
//new 定义
func NewConn() *Conn {
return &Conn{}
}
//函数
func (c *Conn) foo() bool {
...
}
/*
struct 2
*/
//struct定义
type Conn2 struct {
Name string
}
//new 定义
func NewConn2() *Conn {
return &Conn2{}
}
//函数
func (c *Conn2) foo() bool {
...
}
```

0 comments on commit b5def45

Please sign in to comment.