func usage() { … } var doc … func main() { … } type nodelist … func (l nodelist) println(sep string) { … } type nodeset … func (s nodeset) sort() nodelist { … } func (s nodeset) addAll(x nodeset) { … } type graph … func (g graph) addNode(node string) nodeset { … } func (g graph) addEdges(from string, to ...string) { … } func (g graph) nodelist() nodelist { … } func (g graph) reachableFrom(roots nodeset) nodeset { … } func (g graph) transpose() graph { … } func (g graph) sccs() []nodeset { … } func (g graph) allpaths(from, to string) error { … } func (g graph) somepath(from, to string) error { … } func (g graph) toDot(w *bytes.Buffer) { … } func parse(rd io.Reader) (graph, error) { … } var stdin … var stdout … func digraph(cmd string, args []string) error { … } // split splits a line into words, which are generally separated by // spaces, but Go-style double-quoted string literals are also supported. // (This approximates the behaviour of the Bourne shell.) // // `one "two three"` -> ["one" "two three"] // `a"\n"b` -> ["a\nb"] func split(line string) ([]string, error) { … } // quotedLength returns the length in bytes of the prefix of input that // contain a possibly-valid double-quoted Go string literal. // // On success, n is at least two (""); input[:n] may be passed to // strconv.Unquote to interpret its value, and input[n:] contains the // rest of the input. // // On failure, quotedLength returns false, and the entire input can be // passed to strconv.Unquote if an informative error message is desired. // // quotedLength does not and need not detect all errors, such as // invalid hex or octal escape sequences, since it assumes // strconv.Unquote will be applied to the prefix. It guarantees only // that if there is a prefix of input containing a valid string literal, // its length is returned. // // TODO(adonovan): move this into a strconv-like utility package. func quotedLength(input string) (n int, ok bool) { … }