Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 956 Bytes

go.md

File metadata and controls

31 lines (23 loc) · 956 Bytes

Golang best practices we follow

  1. Functions that return something are given noun-like names
func (c *Config) GetJobName(key string) (value string, ok bool)  // not okay
func (c *Config) JobName(key string) (value string, ok bool)  // okay
  1. Functions that do something are given verb-like names
func (c *Config) WriteDetail(w io.Writer) (int64, error)  // okay
  1. Identical functions that differ only by the types involved include the name of the type at the end of the name.
func ParseInt(input string) (int, error)  // okay
func ParseInt64(input string) (int64, error)  // okay
func AppendInt(buf []byte, value int) []byte  // okay
func AppendInt64(buf []byte, value int64) []byte  // okay
  1. If there is a clear “primary” version, the type can be omitted from the name for that version:
func (c *Config) Marshal() ([]byte, error)  // okay
func (c *Config) MarshalText() (string, error)  // okay