Skip to content

Commit

Permalink
golint utils
Browse files Browse the repository at this point in the history
  • Loading branch information
astaxie committed Sep 14, 2015
1 parent 5015614 commit c644872
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion utils/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"runtime"
)

// get function name
// GetFuncName get function name
func GetFuncName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
8 changes: 4 additions & 4 deletions utils/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ type pointerInfo struct {
used []int
}

// print the data in console
// Display print the data in console
func Display(data ...interface{}) {
display(true, data...)
}

// return data print string
// GetDisplayString return data print string
func GetDisplayString(data ...interface{}) string {
return display(false, data...)
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func fomateinfo(headlen int, data ...interface{}) []byte {
for k, v := range data {
var buf2 = new(bytes.Buffer)
var pointers *pointerInfo
var interfaces []reflect.Value = make([]reflect.Value, 0, 10)
var interfaces = make([]reflect.Value, 0, 10)

printKeyValue(buf2, reflect.ValueOf(v), &pointers, &interfaces, nil, true, " ", 1)

Expand Down Expand Up @@ -385,7 +385,7 @@ func printPointerInfo(buf *bytes.Buffer, headlen int, pointers *pointerInfo) {
if len(p.used) > 0 {
anyused = true
}
pointerNum += 1
pointerNum++
p.n = pointerNum
}

Expand Down
4 changes: 2 additions & 2 deletions utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func FileExists(name string) bool {
return true
}

// Search a file in paths.
// SearchFile Search a file in paths.
// this is often used in search config file in /etc ~/
func SearchFile(filename string, paths ...string) (fullpath string, err error) {
for _, path := range paths {
Expand All @@ -56,7 +56,7 @@ func SearchFile(filename string, paths ...string) (fullpath string, err error) {
return
}

// like command grep -E
// GrepFile like command grep -E
// for example: GrepFile(`^hello`, "hello.txt")
// \n is striped while read
func GrepFile(patten string, filename string) (lines []string, err error) {
Expand Down
5 changes: 3 additions & 2 deletions utils/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewEMail(config string) *Email {
return e
}

// Make all send information to byte
// Bytes Make all send information to byte
func (e *Email) Bytes() ([]byte, error) {
buff := &bytes.Buffer{}
w := multipart.NewWriter(buff)
Expand Down Expand Up @@ -156,7 +156,7 @@ func (e *Email) Bytes() ([]byte, error) {
return buff.Bytes(), nil
}

// Add attach file to the send mail
// AttachFile Add attach file to the send mail
func (e *Email) AttachFile(args ...string) (a *Attachment, err error) {
if len(args) < 1 && len(args) > 2 {
err = errors.New("Must specify a file name and number of parameters can not exceed at least two")
Expand Down Expand Up @@ -215,6 +215,7 @@ func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachm
return at, nil
}

// Send will send out the mail
func (e *Email) Send() error {
if e.Auth == nil {
e.Auth = smtp.PlainAuth(e.Identity, e.Username, e.Password, e.Host)
Expand Down
5 changes: 3 additions & 2 deletions utils/safemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"sync"
)

// BeeMap is a map with lock
type BeeMap struct {
lock *sync.RWMutex
bm map[interface{}]interface{}
Expand All @@ -41,7 +42,7 @@ func (m *BeeMap) Get(k interface{}) interface{} {
return nil
}

// Maps the given key and value. Returns false
// Set Maps the given key and value. Returns false
// if the key is already in the map and changes nothing.
func (m *BeeMap) Set(k interface{}, v interface{}) bool {
m.lock.Lock()
Expand All @@ -56,7 +57,7 @@ func (m *BeeMap) Set(k interface{}, v interface{}) bool {
return true
}

// Returns true if k is exist in the map.
// Check Returns true if k is exist in the map.
func (m *BeeMap) Check(k interface{}) bool {
m.lock.RLock()
defer m.lock.RUnlock()
Expand Down
2 changes: 1 addition & 1 deletion utils/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{}) {
return
}

// SliceChuck separates one slice to some sized slice.
// SliceChunk separates one slice to some sized slice.
func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{}) {
if size >= len(slice) {
chunkslice = append(chunkslice, slice)
Expand Down

0 comments on commit c644872

Please sign in to comment.