-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
38 lines (38 loc) · 1.3 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Muster is a tool to automate the creation of Must funcs. Must funcs panic
// if the last result of a method is not nil. Muster should only be used on
// funcs/methods that return an error as the last result.
//
// Muster works on normal funcs as well as receiver funcs (methods).
//
// For example, given this snippet,
//
// package person
//
// func DoGood(name str) error {
// return errors.New("bad")
// }
//
// running this command
//
// muster -func=DoGood
//
// in the same directory will create the file dogood_must.go, in package person,
// containing a definition of
//
// func MustDoGood(name string)
//
// That method will panic if the result of DoGood is not nil.
//
// Typically this process would be run using go generate, like this:
//
// //go:generate muster -func=DoGood
//
// With no arguments, it processes the package in the current directory.
// Otherwise, the arguments must name a single directory holding a Go package
// or a set of Go source files that represent a single Go package.
//
// The -func flag accepts a comma-separated list of types so a single run can
// generate methods for multiple types. The default output file is f_must.go,
// where f is the lower-cased name of the first func listed. It can be overridden
// with the -output flag.
package main // import "github.com/vivalldi/muster"