These are the Go language-specific coding styles. Anything mentions here overrides/adds to the "In General" guides.
The Go communities and development team had spend almost all their strength to develop such a powerful linter checking. Use them before committing the codes.
/*Package regexp implements a simple library for regular expressions.The syntax of the regular expressions accepted is: regexp: concatenation { '|' concatenation } concatenation: { closure } closure: term [ '*' | '+' | '?' ] term: '^' '$' '.' character '[' [ '^' ] character-ranges ']' '(' regexp ')'*/package regexperror approachpanic without encouraging recovery() approachlog.Printf("Reading %s: %v", filename, err).CamelCase convention.camelCase for private functions, big CamelCase for public functions and APIThese are the proper Go practices:
// Declare but not initialized - use varvar players int // 0var things []Thing // an empty slice of Thingsvar thing Thing // empty Thing struct// Declare and initialized - use :=min, max := 0, 1000things := nilthing := &Thing{}// ambiguous types, use either but clarify up with function or typevar length uint32 = 0x80length := uint32(0x80)func main() { r, err := Open("a") if err != nil { log.Fatalf("error opening 'a'\n") } defer func() { err := r.Close() if err != nil { log.Fatal(err) } }() r, err = Open("b") if err != nil { log.Fatalf("error opening 'b'\n") } defer func() { err := r.Close() if err != nil { log.Fatal(err) } }()}That's all about Go coding styles conventions.