proverbs

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 5 Imported by: 10

README

Go Proverbs

In 2015, Rob Pike (one of Go's creators) gave a talk at Gopherfest SV 2015 where he outlined what have become known as "Go Proverbs", a set of principles that every Go developer should keep in mind when working with the programming language.

This package simply exposes those proverbs and their relevant locations in the talk video.

Go Report Card GoDoc CircleCI

Usage

Random Proverb
package main

import "github.com/jboursiquot/go-proverbs"

func main() {
  fmt.Println(proverbs.Random())
  fmt.Println(proverbs.Random())
  fmt.Println(proverbs.Random())
}
Result
&{With the unsafe package there are no guarantees. https://www.youtube.com/watch?v=PAAkCSZUG1c&t=13m49s}
&{Reflection is never clear. https://www.youtube.com/watch?v=PAAkCSZUG1c&t=15m22s}
&{A little copying is better than a little dependency. https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s}
Nth Proverb
package main

import "github.com/jboursiquot/go-proverbs"

func main() {
  p, err := proverbs.Nth(4)
  if err != nil {
    fmt.Println(err)
  }
  fmt.Printf("%+v\n", p)
}
Result
&{Saying:Make the zero value useful. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=6m25s}
All Proverbs
package main

import "github.com/jboursiquot/go-proverbs"

func main() {
  list, err := proverbs.All()
  if err != nil {
    fmt.Println(err)
  }
  for _, p := range list {
    fmt.Printf("%+v\n", p)
  }
}

Result
&{Saying:The bigger the interface, the weaker the abstraction. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=5m17s}
&{Saying:Syscall must always be guarded with build tags. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=11m10s}
&{Saying:Cgo must always be guarded with build tags. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=11m53s}
&{Saying:Errors are values. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=16m13s}
&{Saying:Concurrency is not parallelism. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=3m42s}
&{Saying:Channels orchestrate; mutexes serialize. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=4m20s}
&{Saying:Ggo is not Go. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=12m37s}
&{Saying:A little copying is better than a little dependency. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=9m28s}
&{Saying:Documentation is for users. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=19m07s}
&{Saying:Don't panic. Link:https://github.com/golang/go/wiki/CodeReviewComments#dont-panic}
&{Saying:Make the zero value useful. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=6m25s}
&{Saying:Gofmt's style is no one's favorite, yet gofmt is everyone's favorite. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=8m43s}
&{Saying:With the unsafe package there are no guarantees. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=13m49s}
&{Saying:Clear is better than clever. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=14m35s}
&{Saying:Reflection is never clear. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=15m22s}
&{Saying:Don't just check errors, handle them gracefully. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=17m25s}
&{Saying:Design the architecture, name the components, document the details. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=18m09s}
&{Saying:Don't communicate by sharing memory, share memory by communicating. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=2m48s}
&{Saying:interface{} says nothing. Link:https://www.youtube.com/watch?v=PAAkCSZUG1c&t=7m36s}

License

MIT

Documentation

Overview

Package proverbs is inpired by a talk given from Rob Pike (co-creator of Go) at Gopherfest SV 2015. Each proverb contains a link to the position in the recorded talk where the saying is talked about.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrNthProverbNotFound

type ErrNthProverbNotFound struct {
	N int
}

ErrNthProverbNotFound is returned when the requested nth proverb isn't found in the dictionary of proverbs.

func (*ErrNthProverbNotFound) Error

func (e *ErrNthProverbNotFound) Error() string

type Proverb

type Proverb struct {
	Saying string
	Link   string
}

Proverb includes the proverb and a link to the talk at the position where it's talked about.

func All

func All() ([]*Proverb, error)

All returns all the Proverbs.

func Nth

func Nth(n int) (*Proverb, error)

Nth returns the nth proverb from the list.

func Random

func Random() *Proverb

Random returns a random Proverb.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL