Showing preview only (237K chars total). Download the full file or copy to clipboard to get everything.
Repository: ericchiang/pup
Branch: master
Commit: 5a57cf111366
Files: 18
Total size: 228.4 KB
Directory structure:
gitextract_hf53ko4u/
├── .github/
│ └── workflows/
│ └── test.yaml
├── .gitignore
├── LICENSE
├── README.md
├── display.go
├── go.mod
├── go.sum
├── parse.go
├── parse_test.go
├── pup.go
├── pup.rb
├── selector.go
└── tests/
├── README.md
├── cmds.txt
├── expected_output.txt
├── index.html
├── run.py
└── test
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/test.yaml
================================================
name: test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
go-version: [1.17.x, 1.16.x]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: go build ./...
- name: Test
run: go test -v ./...
================================================
FILE: .gitignore
================================================
dist/
testpages/*
tests/test_results.txt
robots.html
================================================
FILE: LICENSE
================================================
Copyright (c) 2014: Eric Chiang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
# pup
pup is a command line tool for processing HTML. It reads from stdin,
prints to stdout, and allows the user to filter parts of the page using
[CSS selectors](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/Selectors).
Inspired by [jq](http://stedolan.github.io/jq/), pup aims to be a
fast and flexible way of exploring HTML from the terminal.
## Install
Direct downloads are available through the [releases page](https://github.com/EricChiang/pup/releases/latest).
If you have Go installed on your computer just run `go get`.
go get github.com/ericchiang/pup
If you're on OS X, use [Homebrew](http://brew.sh/) to install (no Go required).
brew install https://raw.githubusercontent.com/EricChiang/pup/master/pup.rb
## Quick start
```bash
$ curl -s https://news.ycombinator.com/
```
Ew, HTML. Let's run that through some pup selectors:
```bash
$ curl -s https://news.ycombinator.com/ | pup 'table table tr:nth-last-of-type(n+2) td.title a'
```
Okay, how about only the links?
```bash
$ curl -s https://news.ycombinator.com/ | pup 'table table tr:nth-last-of-type(n+2) td.title a attr{href}'
```
Even better, let's grab the titles too:
```bash
$ curl -s https://news.ycombinator.com/ | pup 'table table tr:nth-last-of-type(n+2) td.title a json{}'
```
## Basic Usage
```bash
$ cat index.html | pup [flags] '[selectors] [display function]'
```
## Examples
Download a webpage with wget.
```bash
$ wget http://en.wikipedia.org/wiki/Robots_exclusion_standard -O robots.html
```
#### Clean and indent
By default pup will fill in missing tags and properly indent the page.
```bash
$ cat robots.html
# nasty looking HTML
$ cat robots.html | pup --color
# cleaned, indented, and colorful HTML
```
#### Filter by tag
```bash
$ cat robots.html | pup 'title'
<title>
Robots exclusion standard - Wikipedia, the free encyclopedia
</title>
```
#### Filter by id
```bash
$ cat robots.html | pup 'span#See_also'
<span class="mw-headline" id="See_also">
See also
</span>
```
#### Filter by attribute
```bash
$ cat robots.html | pup 'th[scope="row"]'
<th scope="row" class="navbox-group">
Exclusion standards
</th>
<th scope="row" class="navbox-group">
Related marketing topics
</th>
<th scope="row" class="navbox-group">
Search marketing related topics
</th>
<th scope="row" class="navbox-group">
Search engine spam
</th>
<th scope="row" class="navbox-group">
Linking
</th>
<th scope="row" class="navbox-group">
People
</th>
<th scope="row" class="navbox-group">
Other
</th>
```
#### Pseudo Classes
CSS selectors have a group of specifiers called ["pseudo classes"](
https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes) which are pretty
cool. pup implements a majority of the relevant ones them.
Here are some examples.
```bash
$ cat robots.html | pup 'a[rel]:empty'
<a rel="license" href="//creativecommons.org/licenses/by-sa/3.0/" style="display:none;">
</a>
```
```bash
$ cat robots.html | pup ':contains("History")'
<span class="toctext">
History
</span>
<span class="mw-headline" id="History">
History
</span>
```
```bash
$ cat robots.html | pup ':parent-of([action="edit"])'
<span class="wb-langlinks-edit wb-langlinks-link">
<a action="edit" href="//www.wikidata.org/wiki/Q80776#sitelinks-wikipedia" text="Edit links" title="Edit interlanguage links" class="wbc-editpage">
Edit links
</a>
</span>
```
For a complete list, view the [implemented selectors](#implemented-selectors)
section.
#### `+`, `>`, and `,`
These are intermediate characters that declare special instructions. For
instance, a comma `,` allows pup to specify multiple groups of selectors.
```bash
$ cat robots.html | pup 'title, h1 span[dir="auto"]'
<title>
Robots exclusion standard - Wikipedia, the free encyclopedia
</title>
<span dir="auto">
Robots exclusion standard
</span>
```
#### Chain selectors together
When combining selectors, the HTML nodes selected by the previous selector will
be passed to the next ones.
```bash
$ cat robots.html | pup 'h1#firstHeading'
<h1 id="firstHeading" class="firstHeading" lang="en">
<span dir="auto">
Robots exclusion standard
</span>
</h1>
```
```bash
$ cat robots.html | pup 'h1#firstHeading span'
<span dir="auto">
Robots exclusion standard
</span>
```
## Implemented Selectors
For further examples of these selectors head over to [MDN](
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference).
```bash
pup '.class'
pup '#id'
pup 'element'
pup 'selector + selector'
pup 'selector > selector'
pup '[attribute]'
pup '[attribute="value"]'
pup '[attribute*="value"]'
pup '[attribute~="value"]'
pup '[attribute^="value"]'
pup '[attribute$="value"]'
pup ':empty'
pup ':first-child'
pup ':first-of-type'
pup ':last-child'
pup ':last-of-type'
pup ':only-child'
pup ':only-of-type'
pup ':contains("text")'
pup ':nth-child(n)'
pup ':nth-of-type(n)'
pup ':nth-last-child(n)'
pup ':nth-last-of-type(n)'
pup ':not(selector)'
pup ':parent-of(selector)'
```
You can mix and match selectors as you wish.
```bash
cat index.html | pup 'element#id[attribute="value"]:first-of-type'
```
## Display Functions
Non-HTML selectors which effect the output type are implemented as functions
which can be provided as a final argument.
#### `text{}`
Print all text from selected nodes and children in depth first order.
```bash
$ cat robots.html | pup '.mw-headline text{}'
History
About the standard
Disadvantages
Alternatives
Examples
Nonstandard extensions
Crawl-delay directive
Allow directive
Sitemap
Host
Universal "*" match
Meta tags and headers
See also
References
External links
```
#### `attr{attrkey}`
Print the values of all attributes with a given key from all selected nodes.
```bash
$ cat robots.html | pup '.catlinks div attr{id}'
mw-normal-catlinks
mw-hidden-catlinks
```
#### `json{}`
Print HTML as JSON.
```bash
$ cat robots.html | pup 'div#p-namespaces a'
<a href="/wiki/Robots_exclusion_standard" title="View the content page [c]" accesskey="c">
Article
</a>
<a href="/wiki/Talk:Robots_exclusion_standard" title="Discussion about the content page [t]" accesskey="t">
Talk
</a>
```
```bash
$ cat robots.html | pup 'div#p-namespaces a json{}'
[
{
"accesskey": "c",
"href": "/wiki/Robots_exclusion_standard",
"tag": "a",
"text": "Article",
"title": "View the content page [c]"
},
{
"accesskey": "t",
"href": "/wiki/Talk:Robots_exclusion_standard",
"tag": "a",
"text": "Talk",
"title": "Discussion about the content page [t]"
}
]
```
Use the `-i` / `--indent` flag to control the intent level.
```bash
$ cat robots.html | pup -i 4 'div#p-namespaces a json{}'
[
{
"accesskey": "c",
"href": "/wiki/Robots_exclusion_standard",
"tag": "a",
"text": "Article",
"title": "View the content page [c]"
},
{
"accesskey": "t",
"href": "/wiki/Talk:Robots_exclusion_standard",
"tag": "a",
"text": "Talk",
"title": "Discussion about the content page [t]"
}
]
```
If the selectors only return one element the results will be printed as a JSON
object, not a list.
```bash
$ cat robots.html | pup --indent 4 'title json{}'
{
"tag": "title",
"text": "Robots exclusion standard - Wikipedia, the free encyclopedia"
}
```
Because there is no universal standard for converting HTML/XML to JSON, a
method has been chosen which hopefully fits. The goal is simply to get the
output of pup into a more consumable format.
## Flags
Run `pup --help` for a list of further options
================================================
FILE: display.go
================================================
package main
import (
"encoding/json"
"fmt"
"regexp"
"strings"
"github.com/fatih/color"
colorable "github.com/mattn/go-colorable"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
)
func init() {
color.Output = colorable.NewColorableStdout()
}
type Displayer interface {
Display([]*html.Node)
}
func ParseDisplayer(cmd string) error {
attrRe := regexp.MustCompile(`attr\{([a-zA-Z\-]+)\}`)
if cmd == "text{}" {
pupDisplayer = TextDisplayer{}
} else if cmd == "json{}" {
pupDisplayer = JSONDisplayer{}
} else if match := attrRe.FindAllStringSubmatch(cmd, -1); len(match) == 1 {
pupDisplayer = AttrDisplayer{
Attr: match[0][1],
}
} else {
return fmt.Errorf("Unknown displayer")
}
return nil
}
// Is this node a tag with no end tag such as <meta> or <br>?
// http://www.w3.org/TR/html-markup/syntax.html#syntax-elements
func isVoidElement(n *html.Node) bool {
switch n.DataAtom {
case atom.Area, atom.Base, atom.Br, atom.Col, atom.Command, atom.Embed,
atom.Hr, atom.Img, atom.Input, atom.Keygen, atom.Link,
atom.Meta, atom.Param, atom.Source, atom.Track, atom.Wbr:
return true
}
return false
}
var (
// Colors
tagColor *color.Color = color.New(color.FgCyan)
tokenColor = color.New(color.FgCyan)
attrKeyColor = color.New(color.FgMagenta)
quoteColor = color.New(color.FgBlue)
commentColor = color.New(color.FgYellow)
)
type TreeDisplayer struct {
}
func (t TreeDisplayer) Display(nodes []*html.Node) {
for _, node := range nodes {
t.printNode(node, 0)
}
}
// The <pre> tag indicates that the text within it should always be formatted
// as is. See https://github.com/ericchiang/pup/issues/33
func (t TreeDisplayer) printPre(n *html.Node) {
switch n.Type {
case html.TextNode:
s := n.Data
if pupEscapeHTML {
// don't escape javascript
if n.Parent == nil || n.Parent.DataAtom != atom.Script {
s = html.EscapeString(s)
}
}
fmt.Print(s)
for c := n.FirstChild; c != nil; c = c.NextSibling {
t.printPre(c)
}
case html.ElementNode:
fmt.Printf("<%s", n.Data)
for _, a := range n.Attr {
val := a.Val
if pupEscapeHTML {
val = html.EscapeString(val)
}
fmt.Printf(` %s="%s"`, a.Key, val)
}
fmt.Print(">")
if !isVoidElement(n) {
for c := n.FirstChild; c != nil; c = c.NextSibling {
t.printPre(c)
}
fmt.Printf("</%s>", n.Data)
}
case html.CommentNode:
data := n.Data
if pupEscapeHTML {
data = html.EscapeString(data)
}
fmt.Printf("<!--%s-->\n", data)
for c := n.FirstChild; c != nil; c = c.NextSibling {
t.printPre(c)
}
case html.DoctypeNode, html.DocumentNode:
for c := n.FirstChild; c != nil; c = c.NextSibling {
t.printPre(c)
}
}
}
// Print a node and all of it's children to `maxlevel`.
func (t TreeDisplayer) printNode(n *html.Node, level int) {
switch n.Type {
case html.TextNode:
s := n.Data
if pupEscapeHTML {
// don't escape javascript
if n.Parent == nil || n.Parent.DataAtom != atom.Script {
s = html.EscapeString(s)
}
}
s = strings.TrimSpace(s)
if s != "" {
t.printIndent(level)
fmt.Println(s)
}
case html.ElementNode:
t.printIndent(level)
// TODO: allow pre with color
if n.DataAtom == atom.Pre && !pupPrintColor && pupPreformatted {
t.printPre(n)
fmt.Println()
return
}
if pupPrintColor {
tokenColor.Print("<")
tagColor.Printf("%s", n.Data)
} else {
fmt.Printf("<%s", n.Data)
}
for _, a := range n.Attr {
val := a.Val
if pupEscapeHTML {
val = html.EscapeString(val)
}
if pupPrintColor {
fmt.Print(" ")
attrKeyColor.Printf("%s", a.Key)
tokenColor.Print("=")
quoteColor.Printf(`"%s"`, val)
} else {
fmt.Printf(` %s="%s"`, a.Key, val)
}
}
if pupPrintColor {
tokenColor.Println(">")
} else {
fmt.Println(">")
}
if !isVoidElement(n) {
t.printChildren(n, level+1)
t.printIndent(level)
if pupPrintColor {
tokenColor.Print("</")
tagColor.Printf("%s", n.Data)
tokenColor.Println(">")
} else {
fmt.Printf("</%s>\n", n.Data)
}
}
case html.CommentNode:
t.printIndent(level)
data := n.Data
if pupEscapeHTML {
data = html.EscapeString(data)
}
if pupPrintColor {
commentColor.Printf("<!--%s-->\n", data)
} else {
fmt.Printf("<!--%s-->\n", data)
}
t.printChildren(n, level)
case html.DoctypeNode, html.DocumentNode:
t.printChildren(n, level)
}
}
func (t TreeDisplayer) printChildren(n *html.Node, level int) {
if pupMaxPrintLevel > -1 {
if level >= pupMaxPrintLevel {
t.printIndent(level)
fmt.Println("...")
return
}
}
child := n.FirstChild
for child != nil {
t.printNode(child, level)
child = child.NextSibling
}
}
func (t TreeDisplayer) printIndent(level int) {
for ; level > 0; level-- {
fmt.Print(pupIndentString)
}
}
// Print the text of a node
type TextDisplayer struct{}
func (t TextDisplayer) Display(nodes []*html.Node) {
for _, node := range nodes {
if node.Type == html.TextNode {
data := node.Data
if pupEscapeHTML {
// don't escape javascript
if node.Parent == nil || node.Parent.DataAtom != atom.Script {
data = html.EscapeString(data)
}
}
fmt.Println(data)
}
children := []*html.Node{}
child := node.FirstChild
for child != nil {
children = append(children, child)
child = child.NextSibling
}
t.Display(children)
}
}
// Print the attribute of a node
type AttrDisplayer struct {
Attr string
}
func (a AttrDisplayer) Display(nodes []*html.Node) {
for _, node := range nodes {
attributes := node.Attr
for _, attr := range attributes {
if attr.Key == a.Attr {
val := attr.Val
if pupEscapeHTML {
val = html.EscapeString(val)
}
fmt.Printf("%s\n", val)
}
}
}
}
// Print nodes as a JSON list
type JSONDisplayer struct{}
// returns a jsonifiable struct
func jsonify(node *html.Node) map[string]interface{} {
vals := map[string]interface{}{}
if len(node.Attr) > 0 {
for _, attr := range node.Attr {
if pupEscapeHTML {
vals[attr.Key] = html.EscapeString(attr.Val)
} else {
vals[attr.Key] = attr.Val
}
}
}
vals["tag"] = node.DataAtom.String()
children := []interface{}{}
for child := node.FirstChild; child != nil; child = child.NextSibling {
switch child.Type {
case html.ElementNode:
children = append(children, jsonify(child))
case html.TextNode:
text := strings.TrimSpace(child.Data)
if text != "" {
if pupEscapeHTML {
// don't escape javascript
if node.DataAtom != atom.Script {
text = html.EscapeString(text)
}
}
// if there is already text we'll append it
currText, ok := vals["text"]
if ok {
text = fmt.Sprintf("%s %s", currText, text)
}
vals["text"] = text
}
case html.CommentNode:
comment := strings.TrimSpace(child.Data)
if pupEscapeHTML {
comment = html.EscapeString(comment)
}
currComment, ok := vals["comment"]
if ok {
comment = fmt.Sprintf("%s %s", currComment, comment)
}
vals["comment"] = comment
}
}
if len(children) > 0 {
vals["children"] = children
}
return vals
}
func (j JSONDisplayer) Display(nodes []*html.Node) {
var data []byte
var err error
jsonNodes := []map[string]interface{}{}
for _, node := range nodes {
jsonNodes = append(jsonNodes, jsonify(node))
}
data, err = json.MarshalIndent(&jsonNodes, "", pupIndentString)
if err != nil {
panic("Could not jsonify nodes")
}
fmt.Printf("%s\n", data)
}
// Print the number of features returned
type NumDisplayer struct{}
func (d NumDisplayer) Display(nodes []*html.Node) {
fmt.Println(len(nodes))
}
================================================
FILE: go.mod
================================================
module github.com/ericchiang/pup
go 1.13
require (
github.com/fatih/color v1.0.0
github.com/mattn/go-colorable v0.0.5
github.com/mattn/go-isatty v0.0.0-20151211000621-56b76bdf51f7 // indirect
golang.org/x/net v0.0.0-20160720084139-4d38db76854b
golang.org/x/sys v0.0.0-20160717071931-a646d33e2ee3 // indirect
golang.org/x/text v0.0.0-20160719205907-0a5a09ee4409
)
================================================
FILE: go.sum
================================================
github.com/fatih/color v1.0.0 h1:4zdNjpoprR9fed2QRCPb2VTPU4UFXEtJc9Vc+sgXkaQ=
github.com/fatih/color v1.0.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/mattn/go-colorable v0.0.5 h1:X1IeP+MaFWC+vpbhw3y426rQftzXSj+N7eJFnBEMBfE=
github.com/mattn/go-colorable v0.0.5/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.0-20151211000621-56b76bdf51f7 h1:owMyzMR4QR+jSdlfkX9jPU3rsby4++j99BfbtgVr6ZY=
github.com/mattn/go-isatty v0.0.0-20151211000621-56b76bdf51f7/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
golang.org/x/net v0.0.0-20160720084139-4d38db76854b h1:2lHDZItrxmjk3OXnITVKcHWo6qQYJSm4q2pmvciVkxo=
golang.org/x/net v0.0.0-20160720084139-4d38db76854b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20160717071931-a646d33e2ee3 h1:ZLExsLvnoqWSw6JB6k6RjWobIHGR3NG9dzVANJ7SVKc=
golang.org/x/sys v0.0.0-20160717071931-a646d33e2ee3/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.0.0-20160719205907-0a5a09ee4409 h1:ImTDOALQ1AOSGXgapb9Q1tOcHlxpQXZCPSIMKLce0JU=
golang.org/x/text v0.0.0-20160719205907-0a5a09ee4409/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
================================================
FILE: parse.go
================================================
package main
import (
"fmt"
"io"
"os"
"strconv"
"strings"
"golang.org/x/net/html"
"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
)
var (
pupIn io.ReadCloser = os.Stdin
pupCharset string = ""
pupMaxPrintLevel int = -1
pupPreformatted bool = false
pupPrintColor bool = false
pupEscapeHTML bool = true
pupIndentString string = " "
pupDisplayer Displayer = TreeDisplayer{}
)
// Parse the html while handling the charset
func ParseHTML(r io.Reader, cs string) (*html.Node, error) {
var err error
if cs == "" {
// attempt to guess the charset of the HTML document
r, err = charset.NewReader(r, "")
if err != nil {
return nil, err
}
} else {
// let the user specify the charset
e, name := charset.Lookup(cs)
if name == "" {
return nil, fmt.Errorf("'%s' is not a valid charset", cs)
}
r = transform.NewReader(r, e.NewDecoder())
}
return html.Parse(r)
}
func PrintHelp(w io.Writer, exitCode int) {
helpString := `Usage
pup [flags] [selectors] [optional display function]
Version
%s
Flags
-c --color print result with color
-f --file file to read from
-h --help display this help
-i --indent number of spaces to use for indent or character
-n --number print number of elements selected
-l --limit restrict number of levels printed
-p --plain don't escape html
--pre preserve preformatted text
--charset specify the charset for pup to use
--version display version
`
fmt.Fprintf(w, helpString, VERSION)
os.Exit(exitCode)
}
func ParseArgs() ([]string, error) {
cmds, err := ProcessFlags(os.Args[1:])
if err != nil {
return []string{}, err
}
return ParseCommands(strings.Join(cmds, " "))
}
// Process command arguments and return all non-flags.
func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
var i int
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("Option '%s' requires an argument", cmds[i])
}
}()
nonFlagCmds = make([]string, len(cmds))
n := 0
for i = 0; i < len(cmds); i++ {
cmd := cmds[i]
switch cmd {
case "-c", "--color":
pupPrintColor = true
case "-p", "--plain":
pupEscapeHTML = false
case "--pre":
pupPreformatted = true
case "-f", "--file":
filename := cmds[i+1]
pupIn, err = os.Open(filename)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(2)
}
i++
case "-h", "--help":
PrintHelp(os.Stdout, 0)
case "-i", "--indent":
indentLevel, err := strconv.Atoi(cmds[i+1])
if err == nil {
pupIndentString = strings.Repeat(" ", indentLevel)
} else {
pupIndentString = cmds[i+1]
}
i++
case "-l", "--limit":
pupMaxPrintLevel, err = strconv.Atoi(cmds[i+1])
if err != nil {
return []string{}, fmt.Errorf("Argument for '%s' must be numeric", cmd)
}
i++
case "--charset":
pupCharset = cmds[i+1]
i++
case "--version":
fmt.Println(VERSION)
os.Exit(0)
case "-n", "--number":
pupDisplayer = NumDisplayer{}
default:
if cmd[0] == '-' {
return []string{}, fmt.Errorf("Unrecognized flag '%s'", cmd)
}
nonFlagCmds[n] = cmds[i]
n++
}
}
return nonFlagCmds[:n], nil
}
// Split a string with awareness for quoted text and commas
func ParseCommands(cmdString string) ([]string, error) {
cmds := []string{}
last, next, max := 0, 0, len(cmdString)
for {
// if we're at the end of the string, return
if next == max {
if next > last {
cmds = append(cmds, cmdString[last:next])
}
return cmds, nil
}
// evaluate a rune
c := cmdString[next]
switch c {
case ' ':
if next > last {
cmds = append(cmds, cmdString[last:next])
}
last = next + 1
case ',':
if next > last {
cmds = append(cmds, cmdString[last:next])
}
cmds = append(cmds, ",")
last = next + 1
case '\'', '"':
// for quotes, consume runes until the quote has ended
quoteChar := c
for {
next++
if next == max {
return []string{}, fmt.Errorf("Unmatched open quote (%c)", quoteChar)
}
if cmdString[next] == '\\' {
next++
if next == max {
return []string{}, fmt.Errorf("Unmatched open quote (%c)", quoteChar)
}
} else if cmdString[next] == quoteChar {
break
}
}
}
next++
}
}
================================================
FILE: parse_test.go
================================================
package main
import (
"testing"
)
type parseCmdTest struct {
input string
split []string
ok bool
}
var parseCmdTests = []parseCmdTest{
parseCmdTest{`w1 w2`, []string{`w1`, `w2`}, true},
parseCmdTest{`w1 w2 w3`, []string{`w1`, `w2`, `w3`}, true},
parseCmdTest{`w1 'w2 w3'`, []string{`w1`, `'w2 w3'`}, true},
parseCmdTest{`w1 "w2 w3"`, []string{`w1`, `"w2 w3"`}, true},
parseCmdTest{`w1 "w2 w3"`, []string{`w1`, `"w2 w3"`}, true},
parseCmdTest{`w1 'w2 w3'`, []string{`w1`, `'w2 w3'`}, true},
parseCmdTest{`w1"w2 w3"`, []string{`w1"w2 w3"`}, true},
parseCmdTest{`w1'w2 w3'`, []string{`w1'w2 w3'`}, true},
parseCmdTest{`w1"w2 'w3"`, []string{`w1"w2 'w3"`}, true},
parseCmdTest{`w1'w2 "w3'`, []string{`w1'w2 "w3'`}, true},
parseCmdTest{`"w1 w2" "w3"`, []string{`"w1 w2"`, `"w3"`}, true},
parseCmdTest{`'w1 w2' "w3"`, []string{`'w1 w2'`, `"w3"`}, true},
parseCmdTest{`'w1 \'w2' "w3"`, []string{`'w1 \'w2'`, `"w3"`}, true},
parseCmdTest{`'w1 \'w2 "w3"`, []string{}, false},
parseCmdTest{`w1 'w2 w3'"`, []string{}, false},
parseCmdTest{`w1 "w2 w3"'`, []string{}, false},
parseCmdTest{`w1 ' "w2 w3"`, []string{}, false},
parseCmdTest{`w1 " 'w2 w3'`, []string{}, false},
parseCmdTest{`w1"w2 w3""`, []string{}, false},
parseCmdTest{`w1'w2 w3''`, []string{}, false},
parseCmdTest{`w1"w2 'w3""`, []string{}, false},
parseCmdTest{`w1'w2 "w3''`, []string{}, false},
parseCmdTest{`"w1 w2" "w3"'`, []string{}, false},
parseCmdTest{`'w1 w2' "w3"'`, []string{}, false},
parseCmdTest{`w1,"w2 w3"`, []string{`w1`, `,`, `"w2 w3"`}, true},
parseCmdTest{`w1,'w2 w3'`, []string{`w1`, `,`, `'w2 w3'`}, true},
parseCmdTest{`w1 , "w2 w3"`, []string{`w1`, `,`, `"w2 w3"`}, true},
parseCmdTest{`w1 , 'w2 w3'`, []string{`w1`, `,`, `'w2 w3'`}, true},
parseCmdTest{`w1, "w2 w3"`, []string{`w1`, `,`, `"w2 w3"`}, true},
parseCmdTest{`w1, 'w2 w3'`, []string{`w1`, `,`, `'w2 w3'`}, true},
parseCmdTest{`w1 ,"w2 w3"`, []string{`w1`, `,`, `"w2 w3"`}, true},
parseCmdTest{`w1 ,'w2 w3'`, []string{`w1`, `,`, `'w2 w3'`}, true},
parseCmdTest{`w1"w2, w3"`, []string{`w1"w2, w3"`}, true},
parseCmdTest{`w1'w2, w3'`, []string{`w1'w2, w3'`}, true},
parseCmdTest{`w1"w2, 'w3"`, []string{`w1"w2, 'w3"`}, true},
parseCmdTest{`w1'w2, "w3'`, []string{`w1'w2, "w3'`}, true},
parseCmdTest{`"w1, w2" "w3"`, []string{`"w1, w2"`, `"w3"`}, true},
parseCmdTest{`'w1, w2' "w3"`, []string{`'w1, w2'`, `"w3"`}, true},
parseCmdTest{`'w1, \'w2' "w3"`, []string{`'w1, \'w2'`, `"w3"`}, true},
parseCmdTest{`h1, .article-teaser, .article-content`, []string{
`h1`, `,`, `.article-teaser`, `,`, `.article-content`,
}, true},
parseCmdTest{`h1 ,.article-teaser ,.article-content`, []string{
`h1`, `,`, `.article-teaser`, `,`, `.article-content`,
}, true},
parseCmdTest{`h1 , .article-teaser , .article-content`, []string{
`h1`, `,`, `.article-teaser`, `,`, `.article-content`,
}, true},
}
func sliceEq(s1, s2 []string) bool {
if len(s1) != len(s2) {
return false
}
for i := range s1 {
if s1[i] != s2[i] {
return false
}
}
return true
}
func TestParseCommands(t *testing.T) {
for _, test := range parseCmdTests {
parsed, err := ParseCommands(test.input)
if test.ok != (err == nil) {
t.Errorf("`%s`: should have cause error? %v", test.input, !test.ok)
} else if !sliceEq(test.split, parsed) {
t.Errorf("`%s`: `%s`: `%s`", test.input, test.split, parsed)
}
}
}
================================================
FILE: pup.go
================================================
package main
import (
"fmt"
"os"
"golang.org/x/net/html"
)
// _=,_
// o_/6 /#\
// \__ |##/
// ='|--\
// / #'-.
// \#|_ _'-. /
// |/ \_( # |"
// C/ ,--___/
var VERSION string = "0.4.0"
func main() {
// process flags and arguments
cmds, err := ParseArgs()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(2)
}
// Parse the input and get the root node
root, err := ParseHTML(pupIn, pupCharset)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(2)
}
pupIn.Close()
// Parse the selectors
selectorFuncs := []SelectorFunc{}
funcGenerator := Select
var cmd string
for len(cmds) > 0 {
cmd, cmds = cmds[0], cmds[1:]
if len(cmds) == 0 {
if err := ParseDisplayer(cmd); err == nil {
continue
}
}
switch cmd {
case "*": // select all
continue
case ">":
funcGenerator = SelectFromChildren
case "+":
funcGenerator = SelectNextSibling
case ",": // nil will signify a comma
selectorFuncs = append(selectorFuncs, nil)
default:
selector, err := ParseSelector(cmd)
if err != nil {
fmt.Fprintf(os.Stderr, "Selector parsing error: %s\n", err.Error())
os.Exit(2)
}
selectorFuncs = append(selectorFuncs, funcGenerator(selector))
funcGenerator = Select
}
}
selectedNodes := []*html.Node{}
currNodes := []*html.Node{root}
for _, selectorFunc := range selectorFuncs {
if selectorFunc == nil { // hit a comma
selectedNodes = append(selectedNodes, currNodes...)
currNodes = []*html.Node{root}
} else {
currNodes = selectorFunc(currNodes)
}
}
selectedNodes = append(selectedNodes, currNodes...)
pupDisplayer.Display(selectedNodes)
}
================================================
FILE: pup.rb
================================================
# This file was generated by release.sh
require 'formula'
class Pup < Formula
homepage 'https://github.com/ericchiang/pup'
version '0.4.0'
if Hardware::CPU.is_64_bit?
url 'https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_darwin_amd64.zip'
sha256 'c539a697efee2f8e56614a54cb3b215338e00de1f6a7c2fa93144ab6e1db8ebe'
else
url 'https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_darwin_386.zip'
sha256 '75c27caa0008a9cc639beb7506077ad9f32facbffcc4e815e999eaf9588a527e'
end
def install
bin.install 'pup'
end
end
================================================
FILE: selector.go
================================================
package main
import (
"bytes"
"fmt"
"regexp"
"strconv"
"strings"
"text/scanner"
"golang.org/x/net/html"
)
type Selector interface {
Match(node *html.Node) bool
}
type SelectorFunc func(nodes []*html.Node) []*html.Node
func Select(s Selector) SelectorFunc {
// have to define first to be able to do recursion
var selectChildren func(node *html.Node) []*html.Node
selectChildren = func(node *html.Node) []*html.Node {
selected := []*html.Node{}
for child := node.FirstChild; child != nil; child = child.NextSibling {
if s.Match(child) {
selected = append(selected, child)
} else {
selected = append(selected, selectChildren(child)...)
}
}
return selected
}
return func(nodes []*html.Node) []*html.Node {
selected := []*html.Node{}
for _, node := range nodes {
selected = append(selected, selectChildren(node)...)
}
return selected
}
}
// Defined for the '>' selector
func SelectNextSibling(s Selector) SelectorFunc {
return func(nodes []*html.Node) []*html.Node {
selected := []*html.Node{}
for _, node := range nodes {
for ns := node.NextSibling; ns != nil; ns = ns.NextSibling {
if ns.Type == html.ElementNode {
if s.Match(ns) {
selected = append(selected, ns)
}
break
}
}
}
return selected
}
}
// Defined for the '+' selector
func SelectFromChildren(s Selector) SelectorFunc {
return func(nodes []*html.Node) []*html.Node {
selected := []*html.Node{}
for _, node := range nodes {
for c := node.FirstChild; c != nil; c = c.NextSibling {
if s.Match(c) {
selected = append(selected, c)
}
}
}
return selected
}
}
type PseudoClass func(*html.Node) bool
type CSSSelector struct {
Tag string
Attrs map[string]*regexp.Regexp
Pseudo PseudoClass
}
func (s CSSSelector) Match(node *html.Node) bool {
if node.Type != html.ElementNode {
return false
}
if s.Tag != "" {
if s.Tag != node.DataAtom.String() {
return false
}
}
for attrKey, matcher := range s.Attrs {
matched := false
for _, attr := range node.Attr {
if attrKey == attr.Key {
if !matcher.MatchString(attr.Val) {
return false
}
matched = true
break
}
}
if !matched {
return false
}
}
if s.Pseudo == nil {
return true
}
return s.Pseudo(node)
}
// Parse a selector
// e.g. `div#my-button.btn[href^="http"]`
func ParseSelector(cmd string) (selector CSSSelector, err error) {
selector = CSSSelector{
Tag: "",
Attrs: map[string]*regexp.Regexp{},
Pseudo: nil,
}
var s scanner.Scanner
s.Init(strings.NewReader(cmd))
err = ParseTagMatcher(&selector, s)
return
}
// Parse the initial tag
// e.g. `div`
func ParseTagMatcher(selector *CSSSelector, s scanner.Scanner) error {
tag := bytes.NewBuffer([]byte{})
defer func() {
selector.Tag = tag.String()
}()
for {
c := s.Next()
switch c {
case scanner.EOF:
return nil
case '.':
return ParseClassMatcher(selector, s)
case '#':
return ParseIdMatcher(selector, s)
case '[':
return ParseAttrMatcher(selector, s)
case ':':
return ParsePseudo(selector, s)
default:
if _, err := tag.WriteRune(c); err != nil {
return err
}
}
}
}
// Parse a class matcher
// e.g. `.btn`
func ParseClassMatcher(selector *CSSSelector, s scanner.Scanner) error {
var class bytes.Buffer
defer func() {
regexpStr := `(\A|\s)` + regexp.QuoteMeta(class.String()) + `(\s|\z)`
selector.Attrs["class"] = regexp.MustCompile(regexpStr)
}()
for {
c := s.Next()
switch c {
case scanner.EOF:
return nil
case '.':
return ParseClassMatcher(selector, s)
case '#':
return ParseIdMatcher(selector, s)
case '[':
return ParseAttrMatcher(selector, s)
case ':':
return ParsePseudo(selector, s)
default:
if _, err := class.WriteRune(c); err != nil {
return err
}
}
}
}
// Parse an id matcher
// e.g. `#my-picture`
func ParseIdMatcher(selector *CSSSelector, s scanner.Scanner) error {
var id bytes.Buffer
defer func() {
regexpStr := `^` + regexp.QuoteMeta(id.String()) + `$`
selector.Attrs["id"] = regexp.MustCompile(regexpStr)
}()
for {
c := s.Next()
switch c {
case scanner.EOF:
return nil
case '.':
return ParseClassMatcher(selector, s)
case '#':
return ParseIdMatcher(selector, s)
case '[':
return ParseAttrMatcher(selector, s)
case ':':
return ParsePseudo(selector, s)
default:
if _, err := id.WriteRune(c); err != nil {
return err
}
}
}
}
// Parse an attribute matcher
// e.g. `[attr^="http"]`
func ParseAttrMatcher(selector *CSSSelector, s scanner.Scanner) error {
var attrKey bytes.Buffer
var attrVal bytes.Buffer
hasMatchVal := false
matchType := '='
defer func() {
if hasMatchVal {
var regexpStr string
switch matchType {
case '=':
regexpStr = `^` + regexp.QuoteMeta(attrVal.String()) + `$`
case '*':
regexpStr = regexp.QuoteMeta(attrVal.String())
case '$':
regexpStr = regexp.QuoteMeta(attrVal.String()) + `$`
case '^':
regexpStr = `^` + regexp.QuoteMeta(attrVal.String())
case '~':
regexpStr = `(\A|\s)` + regexp.QuoteMeta(attrVal.String()) + `(\s|\z)`
}
selector.Attrs[attrKey.String()] = regexp.MustCompile(regexpStr)
} else {
selector.Attrs[attrKey.String()] = regexp.MustCompile(`^.*$`)
}
}()
// After reaching ']' proceed
proceed := func() error {
switch s.Next() {
case scanner.EOF:
return nil
case '.':
return ParseClassMatcher(selector, s)
case '#':
return ParseIdMatcher(selector, s)
case '[':
return ParseAttrMatcher(selector, s)
case ':':
return ParsePseudo(selector, s)
default:
return fmt.Errorf("Expected selector indicator after ']'")
}
}
// Parse the attribute key matcher
for !hasMatchVal {
c := s.Next()
switch c {
case scanner.EOF:
return fmt.Errorf("Unmatched open brace '['")
case ']':
// No attribute value matcher, proceed!
return proceed()
case '$', '^', '~', '*':
matchType = c
hasMatchVal = true
if s.Next() != '=' {
return fmt.Errorf("'%c' must be followed by a '='", matchType)
}
case '=':
matchType = c
hasMatchVal = true
default:
if _, err := attrKey.WriteRune(c); err != nil {
return err
}
}
}
// figure out if the value is quoted
c := s.Next()
inQuote := false
switch c {
case scanner.EOF:
return fmt.Errorf("Unmatched open brace '['")
case ']':
return proceed()
case '"':
inQuote = true
default:
if _, err := attrVal.WriteRune(c); err != nil {
return err
}
}
if inQuote {
for {
c := s.Next()
switch c {
case '\\':
// consume another character
if c = s.Next(); c == scanner.EOF {
return fmt.Errorf("Unmatched open brace '['")
}
case '"':
switch s.Next() {
case ']':
return proceed()
default:
return fmt.Errorf("Quote must end at ']'")
}
}
if _, err := attrVal.WriteRune(c); err != nil {
return err
}
}
} else {
for {
c := s.Next()
switch c {
case scanner.EOF:
return fmt.Errorf("Unmatched open brace '['")
case ']':
// No attribute value matcher, proceed!
return proceed()
}
if _, err := attrVal.WriteRune(c); err != nil {
return err
}
}
}
}
// Parse the selector after ':'
func ParsePseudo(selector *CSSSelector, s scanner.Scanner) error {
if selector.Pseudo != nil {
return fmt.Errorf("Combined multiple pseudo classes")
}
var b bytes.Buffer
for s.Peek() != scanner.EOF {
if _, err := b.WriteRune(s.Next()); err != nil {
return err
}
}
cmd := b.String()
var err error
switch {
case cmd == "empty":
selector.Pseudo = func(n *html.Node) bool {
return n.FirstChild == nil
}
case cmd == "first-child":
selector.Pseudo = firstChildPseudo
case cmd == "last-child":
selector.Pseudo = lastChildPseudo
case cmd == "only-child":
selector.Pseudo = func(n *html.Node) bool {
return firstChildPseudo(n) && lastChildPseudo(n)
}
case cmd == "first-of-type":
selector.Pseudo = firstOfTypePseudo
case cmd == "last-of-type":
selector.Pseudo = lastOfTypePseudo
case cmd == "only-of-type":
selector.Pseudo = func(n *html.Node) bool {
return firstOfTypePseudo(n) && lastOfTypePseudo(n)
}
case strings.HasPrefix(cmd, "contains("):
selector.Pseudo, err = parseContainsPseudo(cmd[len("contains("):])
if err != nil {
return err
}
case strings.HasPrefix(cmd, "nth-child("),
strings.HasPrefix(cmd, "nth-last-child("),
strings.HasPrefix(cmd, "nth-last-of-type("),
strings.HasPrefix(cmd, "nth-of-type("):
if selector.Pseudo, err = parseNthPseudo(cmd); err != nil {
return err
}
case strings.HasPrefix(cmd, "not("):
if selector.Pseudo, err = parseNotPseudo(cmd[len("not("):]); err != nil {
return err
}
case strings.HasPrefix(cmd, "parent-of("):
if selector.Pseudo, err = parseParentOfPseudo(cmd[len("parent-of("):]); err != nil {
return err
}
default:
return fmt.Errorf("%s not a valid pseudo class", cmd)
}
return nil
}
// :first-of-child
func firstChildPseudo(n *html.Node) bool {
for c := n.PrevSibling; c != nil; c = c.PrevSibling {
if c.Type == html.ElementNode {
return false
}
}
return true
}
// :last-of-child
func lastChildPseudo(n *html.Node) bool {
for c := n.NextSibling; c != nil; c = c.NextSibling {
if c.Type == html.ElementNode {
return false
}
}
return true
}
// :first-of-type
func firstOfTypePseudo(node *html.Node) bool {
if node.Type != html.ElementNode {
return false
}
for n := node.PrevSibling; n != nil; n = n.PrevSibling {
if n.DataAtom == node.DataAtom {
return false
}
}
return true
}
// :last-of-type
func lastOfTypePseudo(node *html.Node) bool {
if node.Type != html.ElementNode {
return false
}
for n := node.NextSibling; n != nil; n = n.NextSibling {
if n.DataAtom == node.DataAtom {
return false
}
}
return true
}
func parseNthPseudo(cmd string) (PseudoClass, error) {
i := strings.IndexRune(cmd, '(')
if i < 0 {
// really, we should never get here
return nil, fmt.Errorf("Fatal error, '%s' does not contain a '('", cmd)
}
pseudoName := cmd[:i]
// Figure out how the counting function works
var countNth func(*html.Node) int
switch pseudoName {
case "nth-child":
countNth = func(n *html.Node) int {
nth := 1
for sib := n.PrevSibling; sib != nil; sib = sib.PrevSibling {
if sib.Type == html.ElementNode {
nth++
}
}
return nth
}
case "nth-of-type":
countNth = func(n *html.Node) int {
nth := 1
for sib := n.PrevSibling; sib != nil; sib = sib.PrevSibling {
if sib.Type == html.ElementNode && sib.DataAtom == n.DataAtom {
nth++
}
}
return nth
}
case "nth-last-child":
countNth = func(n *html.Node) int {
nth := 1
for sib := n.NextSibling; sib != nil; sib = sib.NextSibling {
if sib.Type == html.ElementNode {
nth++
}
}
return nth
}
case "nth-last-of-type":
countNth = func(n *html.Node) int {
nth := 1
for sib := n.NextSibling; sib != nil; sib = sib.NextSibling {
if sib.Type == html.ElementNode && sib.DataAtom == n.DataAtom {
nth++
}
}
return nth
}
default:
return nil, fmt.Errorf("Unrecognized pseudo '%s'", pseudoName)
}
nthString := cmd[i+1:]
i = strings.IndexRune(nthString, ')')
if i < 0 {
return nil, fmt.Errorf("Unmatched '(' for pseudo class %s", pseudoName)
} else if i != len(nthString)-1 {
return nil, fmt.Errorf("%s(n) must end selector", pseudoName)
}
number := nthString[:i]
// Check if the number is 'odd' or 'even'
oddOrEven := -1
switch number {
case "odd":
oddOrEven = 1
case "even":
oddOrEven = 0
}
if oddOrEven > -1 {
return func(n *html.Node) bool {
return n.Type == html.ElementNode && countNth(n)%2 == oddOrEven
}, nil
}
// Check against '3n+4' pattern
r := regexp.MustCompile(`([0-9]+)n[ ]?\+[ ]?([0-9])`)
subMatch := r.FindAllStringSubmatch(number, -1)
if len(subMatch) == 1 && len(subMatch[0]) == 3 {
cycle, _ := strconv.Atoi(subMatch[0][1])
offset, _ := strconv.Atoi(subMatch[0][2])
return func(n *html.Node) bool {
return n.Type == html.ElementNode && countNth(n)%cycle == offset
}, nil
}
// check against 'n+2' pattern
r = regexp.MustCompile(`n[ ]?\+[ ]?([0-9])`)
subMatch = r.FindAllStringSubmatch(number, -1)
if len(subMatch) == 1 && len(subMatch[0]) == 2 {
offset, _ := strconv.Atoi(subMatch[0][1])
return func(n *html.Node) bool {
return n.Type == html.ElementNode && countNth(n) >= offset
}, nil
}
// the only other option is a numeric value
nth, err := strconv.Atoi(nthString[:i])
if err != nil {
return nil, err
} else if nth <= 0 {
return nil, fmt.Errorf("Argument to '%s' must be greater than 0", pseudoName)
}
return func(n *html.Node) bool {
return n.Type == html.ElementNode && countNth(n) == nth
}, nil
}
// Parse a :contains("") selector
// expects the input to be everything after the open parenthesis
// e.g. for `contains("Help")` the argument would be `"Help")`
func parseContainsPseudo(cmd string) (PseudoClass, error) {
var s scanner.Scanner
s.Init(strings.NewReader(cmd))
switch s.Next() {
case '"':
default:
return nil, fmt.Errorf("Malformed 'contains(\"\")' selector")
}
textToContain := bytes.NewBuffer([]byte{})
for {
r := s.Next()
switch r {
case '"':
// ')' then EOF must follow '"'
if s.Next() != ')' {
return nil, fmt.Errorf("Malformed 'contains(\"\")' selector")
}
if s.Next() != scanner.EOF {
return nil, fmt.Errorf("'contains(\"\")' must end selector")
}
text := textToContain.String()
contains := func(node *html.Node) bool {
for c := node.FirstChild; c != nil; c = c.NextSibling {
if c.Type == html.TextNode {
if strings.Contains(c.Data, text) {
return true
}
}
}
return false
}
return contains, nil
case '\\':
s.Next()
case scanner.EOF:
return nil, fmt.Errorf("Malformed 'contains(\"\")' selector")
default:
if _, err := textToContain.WriteRune(r); err != nil {
return nil, err
}
}
}
}
// Parse a :not(selector) selector
// expects the input to be everything after the open parenthesis
// e.g. for `not(div#id)` the argument would be `div#id)`
func parseNotPseudo(cmd string) (PseudoClass, error) {
if len(cmd) < 2 {
return nil, fmt.Errorf("malformed ':not' selector")
}
endQuote, cmd := cmd[len(cmd)-1], cmd[:len(cmd)-1]
selector, err := ParseSelector(cmd)
if err != nil {
return nil, err
}
if endQuote != ')' {
return nil, fmt.Errorf("unmatched '('")
}
return func(n *html.Node) bool {
return !selector.Match(n)
}, nil
}
// Parse a :parent-of(selector) selector
// expects the input to be everything after the open parenthesis
// e.g. for `parent-of(div#id)` the argument would be `div#id)`
func parseParentOfPseudo(cmd string) (PseudoClass, error) {
if len(cmd) < 2 {
return nil, fmt.Errorf("malformed ':parent-of' selector")
}
endQuote, cmd := cmd[len(cmd)-1], cmd[:len(cmd)-1]
selector, err := ParseSelector(cmd)
if err != nil {
return nil, err
}
if endQuote != ')' {
return nil, fmt.Errorf("unmatched '('")
}
return func(n *html.Node) bool {
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type == html.ElementNode && selector.Match(c) {
return true
}
}
return false
}, nil
}
================================================
FILE: tests/README.md
================================================
# Tests
A simple set of tests to help maintain sanity.
These tests don't actually test functionality they only make sure pup behaves
the same after code changes.
`cmds.txt` holds a list of commands to perform on `index.html`.
The output of each of these commands produces a specific sha1sum. The expected
sha1sum of each command is in `expected_output.txt`.
Running the `test` file (just a bash script) will run the tests and diff the
output. If pup has changed at all since the last version, you'll see the sha1sums
that changed and the commands that produced that change.
To overwrite the current sha1sums, just run `python run.py > expected_output.txt`
================================================
FILE: tests/cmds.txt
================================================
#footer
#footer li
#footer li + a
#footer li + a attr{title}
#footer li > li
table li
table li:first-child
table li:first-of-type
table li:last-child
table li:last-of-type
table a[title="The Practice of Programming"]
table a[title="The Practice of Programming"] text{}
json{}
text{}
.after-portlet
.after
:empty
td:empty
.navbox-list li:nth-child(1)
.navbox-list li:nth-child(2)
.navbox-list li:nth-child(3)
.navbox-list li:nth-last-child(1)
.navbox-list li:nth-last-child(2)
.navbox-list li:nth-last-child(3)
.navbox-list li:nth-child(n+1)
.navbox-list li:nth-child(3n+1)
.navbox-list li:nth-last-child(n+1)
.navbox-list li:nth-last-child(3n+1)
:only-child
.navbox-list li:only-child
.summary
[class=summary]
[class="summary"]
#toc
#toc li + a
#toc li + a text{}
#toc li + a json{}
#toc li + a + span
#toc li + span
#toc li > li
li a:not([rel])
link, a
link ,a
link , a
link , a sup
link , a:parent-of(sup)
link , a:parent-of(sup) sup
li --number
li -n
================================================
FILE: tests/expected_output.txt
================================================
c00fef10d36c1166cb5ac886f9d25201b720e37e #footer
a7bb8dbfdd638bacad0aa9dc3674126d396b74e2 #footer li
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li + a attr{title}
da39a3ee5e6b4b0d3255bfef95601890afd80709 #footer li > li
a92e50c09cd56970625ac3b74efbddb83b2731bb table li
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-child
505c04a42e0084cd95560c233bd3a81b2c59352d table li:first-of-type
66950e746590d7f4e9cfe3d1adef42cd0addcf1d table li:last-child
66950e746590d7f4e9cfe3d1adef42cd0addcf1d table li:last-of-type
0a37d612cd4c67a42bd147b1edc5a1128456b017 table a[title="The Practice of Programming"]
0d3918d54f868f13110262ffbb88cbb0b083057d table a[title="The Practice of Programming"] text{}
ecb542a30fc75c71a0c6380692cbbc4266ccbce4 json{}
95ef88ded9dab22ee3206cca47b9c3a376274bda text{}
e4f7358fbb7bb1748a296fa2a7e815fa7de0a08b .after-portlet
da39a3ee5e6b4b0d3255bfef95601890afd80709 .after
5b3020ba03fb43f7cdbcb3924546532b6ec9bd71 :empty
3406ca0f548d66a7351af5411ce945cf67a2f849 td:empty
30fff0af0b1209f216d6e9124e7396c0adfa0758 .navbox-list li:nth-child(1)
a38e26949f047faab5ea7ba2acabff899349ce03 .navbox-list li:nth-child(2)
d954831229a76b888e85149564727776e5a2b37a .navbox-list li:nth-child(3)
d314e83b059bb876b0e5ee76aa92d54987961f9a .navbox-list li:nth-last-child(1)
1f19496e239bca61a1109dbbb8b5e0ab3e302b50 .navbox-list li:nth-last-child(2)
1ec9ebf14fc28c7d2b13e81241a6d2e1608589e8 .navbox-list li:nth-last-child(3)
52e726f0993d2660f0fb3ea85156f6fbcc1cfeee .navbox-list li:nth-child(n+1)
0b20c98650efa5df39d380fea8d5b43f3a08cb66 .navbox-list li:nth-child(3n+1)
52e726f0993d2660f0fb3ea85156f6fbcc1cfeee .navbox-list li:nth-last-child(n+1)
972973fe1e8f63e4481c8641d6169c638a528a6e .navbox-list li:nth-last-child(3n+1)
6c45ee6bca361b8a9baee50a15f575fc6ac73adc :only-child
44c99f6ad37b65dc0893cdcb1c60235d827ee73e .navbox-list li:only-child
641037814e358487d1938fc080e08f72a3846ef8 .summary
641037814e358487d1938fc080e08f72a3846ef8 [class=summary]
641037814e358487d1938fc080e08f72a3846ef8 [class="summary"]
613bf65ac4042b6ee0a7a47f08732fdbe1b5b06b #toc
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a text{}
97d170e1550eee4afc0af065b78cda302a97674c #toc li + a json{}
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + a + span
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li + span
da39a3ee5e6b4b0d3255bfef95601890afd80709 #toc li > li
87eee1189dd5296d6c010a1ad329fc53c6099d72 li a:not([rel])
055f3c98e9160beb13f72f1009ad66b6252a9bba link, a
055f3c98e9160beb13f72f1009ad66b6252a9bba link ,a
055f3c98e9160beb13f72f1009ad66b6252a9bba link , a
0d1f66765d1632c70f8608947890524e78459362 link , a sup
b6a3d6cccd305fcc3e8bf2743c443743bdaaa02b link , a:parent-of(sup)
0d1f66765d1632c70f8608947890524e78459362 link , a:parent-of(sup) sup
da39a3ee5e6b4b0d3255bfef95601890afd80709 li --number
da39a3ee5e6b4b0d3255bfef95601890afd80709 li -n
================================================
FILE: tests/index.html
================================================
<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta charset="UTF-8" />
<title>Go (programming language) - Wikipedia, the free encyclopedia</title>
<meta name="generator" content="MediaWiki 1.25wmf6" />
<link rel="alternate" href="android-app://org.wikipedia/http/en.m.wikipedia.org/wiki/Go_(programming_language)" />
<link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=Go_(programming_language)&action=edit" />
<link rel="edit" title="Edit this page" href="/w/index.php?title=Go_(programming_language)&action=edit" />
<link rel="apple-touch-icon" href="//bits.wikimedia.org/apple-touch/wikipedia.png" />
<link rel="shortcut icon" href="//bits.wikimedia.org/favicon/wikipedia.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="Wikipedia (en)" />
<link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd" />
<link rel="alternate" hreflang="x-default" href="/wiki/Go_(programming_language)" />
<link rel="copyright" href="//creativecommons.org/licenses/by-sa/3.0/" />
<link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom" />
<link rel="canonical" href="http://en.wikipedia.org/wiki/Go_(programming_language)" />
<link rel="stylesheet" href="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&lang=en&modules=ext.gadget.DRN-wizard%2CReferenceTooltips%2Ccharinsert%2Cfeatured-articles-links%2CrefToolbar%2Cteahouse%7Cext.geshi.language.go%7Cext.geshi.local%7Cext.rtlcite%2Cwikihiero%2CwikimediaBadges%7Cext.uls.nojs%7Cext.visualEditor.viewPageTarget.noscript%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.interface%7Cmediawiki.ui.button%7Cskins.vector.styles%7Cwikibase.client.init&only=styles&skin=vector&*" />
<meta name="ResourceLoaderDynamicStyles" content="" />
<link rel="stylesheet" href="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&lang=en&modules=site&only=styles&skin=vector&*" />
<style>a:lang(ar),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}
/* cache key: enwiki:resourceloader:filter:minify-css:7:3904d24a08aa08f6a68dc338f9be277e */</style>
<script src="//bits.wikimedia.org/en.wikipedia.org/load.php?debug=false&lang=en&modules=startup&only=scripts&skin=vector&*"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Go_(programming_language)","wgTitle":"Go (programming language)","wgCurRevisionId":632918619,"wgRevisionId":632918619,"wgArticleId":25039021,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Pages with citations lacking titles","Pages with citations having bare URLs","CS1 errors: missing author or editor","All articles with unsourced statements","Articles with unsourced statements from July 2014","Articles containing potentially dated statements from August 2014","All articles containing potentially dated statements","Articles prone to spam from June 2013","Use dmy dates from August 2011","C programming language family","Concurrent programming languages","Google software","Procedural programming languages","Cross-platform software","Programming languages created in 2009","American inventions","Software using the BSD license","Free compilers and interpreters"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"Go_(programming_language)","wgIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgWikiEditorEnabledModules":{"toolbar":true,"dialogs":true,"hidesig":true,"preview":false,"previewDialog":false,"publish":false},"wgBetaFeaturesFeatures":[],"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgVisualEditor":{"isPageWatched":false,"pageLanguageCode":"en","pageLanguageDir":"ltr","svgMaxSize":4096,"namespacesWithSubpages":{"6":0,"8":0,"1":true,"2":true,"3":true,"4":true,"5":true,"7":true,"9":true,"10":true,"11":true,"12":true,"13":true,"14":true,"15":true,"100":true,"101":true,"102":true,"103":true,"104":true,"105":true,"106":true,"107":true,"108":true,"109":true,"110":true,"111":true,"830":true,"831":true,"447":true,"2600":false,"828":true,"829":true}},"wikilove-recipient":"","wikilove-anon":0,"wgHHVMStart":1412726400000,"wgULSAcceptLanguageList":["en-gb","en-us","en"],"wgULSCurrentAutonym":"English","wgFlaggedRevsParams":{"tags":{"status":{"levels":1,"quality":2,"pristine":3}}},"wgStableRevisionId":null,"wgCategoryTreePageCategoryOptions":"{\"mode\":0,\"hideprefix\":20,\"showcount\":true,\"namespaces\":false}","wgNoticeProject":"wikipedia","wgWikibaseItemId":"Q37227"});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function($,jQuery){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"editfont":"default","editondblclick":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"math":0,"minordefault":0,"newpageshidepatrolled":0,"nickname":"","norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"rcdays":7,"rclimit":50,"rows":25,"showhiddencats":false,"shownumberswatching":1,"showtoolbar":1,"skin":"vector","stubthreshold":0,"thumbsize":4,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":1,"watchdefault":0,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"watchrollback":0,
"wllimit":250,"useeditwarning":1,"prefershttps":1,"flaggedrevssimpleui":1,"flaggedrevsstable":0,"flaggedrevseditdiffs":true,"flaggedrevsviewdiffs":false,"usebetatoolbar":1,"usebetatoolbar-cgd":1,"visualeditor-enable":0,"visualeditor-betatempdisable":0,"visualeditor-enable-experimental":0,"visualeditor-enable-language":0,"visualeditor-hidebetawelcome":0,"wikilove-enabled":1,"echo-subscriptions-web-page-review":true,"echo-subscriptions-email-page-review":false,"ep_showtoplink":false,"ep_bulkdelorgs":false,"ep_bulkdelcourses":true,"ep_showdyk":true,"echo-subscriptions-web-education-program":true,"echo-subscriptions-email-education-program":false,"echo-notify-show-link":true,"echo-show-alert":true,"echo-email-frequency":0,"echo-email-format":"html","echo-subscriptions-email-system":true,"echo-subscriptions-web-system":true,"echo-subscriptions-email-user-rights":true,"echo-subscriptions-web-user-rights":true,"echo-subscriptions-email-other":false,"echo-subscriptions-web-other":true,
"echo-subscriptions-email-edit-user-talk":false,"echo-subscriptions-web-edit-user-talk":true,"echo-subscriptions-email-reverted":false,"echo-subscriptions-web-reverted":true,"echo-subscriptions-email-article-linked":false,"echo-subscriptions-web-article-linked":false,"echo-subscriptions-email-mention":false,"echo-subscriptions-web-mention":true,"echo-subscriptions-web-edit-thank":true,"echo-subscriptions-email-edit-thank":false,"echo-subscriptions-web-flow-discussion":true,"echo-subscriptions-email-flow-discussion":false,"gettingstarted-task-toolbar-show-intro":true,"uls-preferences":"","multimediaviewer-enable":true,"language":"en","variant-gan":"gan","variant-iu":"iu","variant-kk":"kk","variant-ku":"ku","variant-shi":"shi","variant-sr":"sr","variant-tg":"tg","variant-uz":"uz","variant-zh":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":
false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"searchNs100":false,"searchNs101":false,"searchNs108":false,"searchNs109":false,"searchNs118":false,"searchNs119":false,"searchNs446":false,"searchNs447":false,"searchNs710":false,"searchNs711":false,"searchNs828":false,"searchNs829":false,"searchNs2600":false,"gadget-teahouse":1,"gadget-ReferenceTooltips":1,"gadget-geonotice":1,"gadget-DRN-wizard":1,"gadget-charinsert":1,"gadget-refToolbar":1,"gadget-mySandbox":1,"gadget-featured-articles-links":1,"variant":"en"});},{},{});mw.loader.implement("user.tokens",function($,jQuery){mw.user.tokens.set({"editToken":"+\\","patrolToken":"+\\","watchToken":"+\\"});},{},{});
/* cache key: enwiki:resourceloader:filter:minify-js:7:fb6d33a792758dc6c0c50bd882524047 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax","ext.centralauth.centralautologin","mmv.head","ext.visualEditor.viewPageTarget.init","ext.uls.init","ext.uls.interface","ext.centralNotice.bannerController","skins.vector.js"]);
}</script>
<link rel="dns-prefetch" href="//meta.wikimedia.org" />
<!--[if lt IE 7]><style type="text/css">body{behavior:url("/w/static-1.25wmf6/skins/Vector/csshover.min.htc")}</style><![endif]-->
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Go_programming_language skin-vector action-view vector-animateLayout">
<div id="mw-page-base" class="noprint"></div>
<div id="mw-head-base" class="noprint"></div>
<div id="content" class="mw-body" role="main">
<a id="top"></a>
<div id="siteNotice"><!-- CentralNotice --></div>
<div class="mw-indicators">
</div>
<h1 id="firstHeading" class="firstHeading" lang="en"><span dir="auto">Go (programming language)</span></h1>
<div id="bodyContent" class="mw-body-content">
<div id="siteSub">From Wikipedia, the free encyclopedia</div>
<div id="contentSub"></div>
<div id="jump-to-nav" class="mw-jump">
Jump to: <a href="#mw-navigation">navigation</a>, <a href="#p-search">search</a>
</div>
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="hatnote">Not to be confused with <a href="/wiki/Go!_(programming_language)" title="Go! (programming language)">Go! (programming language)</a>, an agent-based language released in 2003.</div>
<table class="infobox vevent" style="border-spacing:3px;width:22em">
<caption class="summary">Go</caption>
<tr>
<td colspan="2" style="text-align:center"><a href="/wiki/File:Golang.png" class="image"><img alt="Golang.png" src="//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Golang.png/300px-Golang.png" width="300" height="108" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/2/23/Golang.png/450px-Golang.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/2/23/Golang.png/600px-Golang.png 2x" data-file-width="1224" data-file-height="440" /></a></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Programming_paradigm" title="Programming paradigm">Paradigm(s)</a></th>
<td><a href="/wiki/Compiled_language" title="Compiled language">compiled</a>, <a href="/wiki/Concurrent_programming" title="Concurrent programming" class="mw-redirect">concurrent</a>, <a href="/wiki/Imperative_programming" title="Imperative programming">imperative</a>, <a href="/wiki/Structured_programming" title="Structured programming">structured</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Software_design" title="Software design">Designed by</a></th>
<td><a href="/wiki/Robert_Griesemer" title="Robert Griesemer">Robert Griesemer</a><br />
<a href="/wiki/Rob_Pike" title="Rob Pike">Rob Pike</a><br />
<a href="/wiki/Ken_Thompson" title="Ken Thompson">Ken Thompson</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Software_developer" title="Software developer">Developer</a></th>
<td class="organiser"><a href="/wiki/Google" title="Google">Google Inc.</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left">Appeared in</th>
<td>2009<span class="noprint">; 5 years ago</span><span style="display:none"> (<span class="bday dtstart published updated">2009</span>)</span></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Software_release_life_cycle" title="Software release life cycle">Stable release</a></th>
<td>version 1.3.3<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span>[</span>1<span>]</span></a></sup> / 1 October 2014<span class="noprint">; 39 days ago</span><span style="display:none"> (<span class="bday dtstart published updated">2014-10-01</span>)</span></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Type_system" title="Type system">Typing discipline</a></th>
<td><a href="/wiki/Strong_typing" title="Strong typing" class="mw-redirect">strong</a>, <a href="/wiki/Static_typing" title="Static typing" class="mw-redirect">static</a>, <a href="/wiki/Type_inference" title="Type inference">inferred</a>, <a href="/wiki/Nominal_typing" title="Nominal typing" class="mw-redirect">nominal</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Programming_language_implementation" title="Programming language implementation">Major implementations</a></th>
<td>gc (8g, 6g, 5g), gccgo</td>
</tr>
<tr>
<th scope="row" style="text-align:left">Influenced by</th>
<td><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>, <a href="/wiki/Occam_(programming_language)" title="Occam (programming language)">occam</a>, <a href="/wiki/Limbo_(programming_language)" title="Limbo (programming language)">Limbo</a>, <a href="/wiki/Modula" title="Modula">Modula</a>, <a href="/wiki/Newsqueak" title="Newsqueak">Newsqueak</a>, <a href="/wiki/Oberon_(programming_language)" title="Oberon (programming language)">Oberon</a>, <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>,<sup id="cite_ref-langfaq_2-0" class="reference"><a href="#cite_note-langfaq-2"><span>[</span>2<span>]</span></a></sup> <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a><sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="This claim needs references to reliable sources. (July 2014)">citation needed</span></a></i>]</sup></td>
</tr>
<tr>
<th scope="row" style="text-align:left">Implementation language</th>
<td><a href="/wiki/C_(programming_language)" title="C (programming language)">C</a>, Go, <a href="/wiki/Assembly_language" title="Assembly language">Asm</a></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Operating_system" title="Operating system">OS</a></th>
<td><a href="/wiki/Linux" title="Linux">Linux</a>, <a href="/wiki/Mac_OS_X" title="Mac OS X" class="mw-redirect">Mac OS X</a>, <a href="/wiki/FreeBSD" title="FreeBSD">FreeBSD</a>, <a href="/wiki/NetBSD" title="NetBSD">NetBSD</a>, <a href="/wiki/OpenBSD" title="OpenBSD">OpenBSD</a>, <a href="/wiki/Microsoft_Windows" title="Microsoft Windows">MS Windows</a>, <a href="/wiki/Plan_9_from_Bell_Labs" title="Plan 9 from Bell Labs">Plan 9</a><sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span>[</span>3<span>]</span></a></sup></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Software_license" title="Software license">License</a></th>
<td><a href="/wiki/BSD_licenses" title="BSD licenses">BSD</a>-style<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span>[</span>4<span>]</span></a></sup> + Patent grant<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span>[</span>5<span>]</span></a></sup></td>
</tr>
<tr>
<th scope="row" style="text-align:left"><a href="/wiki/Filename_extension" title="Filename extension">Filename extension(s)</a></th>
<td>.go</td>
</tr>
<tr>
<th scope="row" style="text-align:left">Website</th>
<td><span class="url"><a rel="nofollow" class="external text" href="https://golang.org">golang.org</a></span></td>
</tr>
</table>
<p><b>Go</b>, also commonly referred to as <b>golang</b>, is a programming language initially developed at <a href="/wiki/Google" title="Google">Google</a><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span>[</span>6<span>]</span></a></sup> in 2007 by <a href="/wiki/Robert_Griesemer" title="Robert Griesemer">Robert Griesemer</a>, <a href="/wiki/Rob_Pike" title="Rob Pike">Rob Pike</a>, and <a href="/wiki/Ken_Thompson" title="Ken Thompson">Ken Thompson</a>.<sup id="cite_ref-langfaq_2-1" class="reference"><a href="#cite_note-langfaq-2"><span>[</span>2<span>]</span></a></sup> It is a statically-<a href="/wiki/Type_system" title="Type system">typed</a> language with syntax loosely derived from that of C, adding <a href="/wiki/Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collection</a>, <a href="/wiki/Type_safety" title="Type safety">type safety</a>, some <a href="/wiki/Dynamic_typing" title="Dynamic typing" class="mw-redirect">dynamic-typing</a> capabilities, additional built-in types such as <a href="/wiki/Variable-length_array" title="Variable-length array">variable-length arrays</a> and key-value maps, and a large standard library.</p>
<p>The language was announced in November 2009 and is now used in some of Google's production systems.<sup id="cite_ref-faq_7-0" class="reference"><a href="#cite_note-faq-7"><span>[</span>7<span>]</span></a></sup> Go's "gc" compiler targets the <a href="/wiki/Linux" title="Linux">Linux</a>, <a href="/wiki/Mac_OS_X" title="Mac OS X" class="mw-redirect">Mac OS X</a>, <a href="/wiki/FreeBSD" title="FreeBSD">FreeBSD</a>, <a href="/wiki/NetBSD" title="NetBSD">NetBSD</a>, <a href="/wiki/OpenBSD" title="OpenBSD">OpenBSD</a>, <a href="/wiki/Plan_9_from_Bell_Labs" title="Plan 9 from Bell Labs">Plan 9</a>, and <a href="/wiki/Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a> operating systems and the <a href="/wiki/I386" title="I386" class="mw-redirect">i386</a>, <a href="/wiki/Amd64" title="Amd64" class="mw-redirect">amd64</a>, and <a href="/wiki/ARM_architecture" title="ARM architecture">ARM</a> processor architectures.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span>[</span>8<span>]</span></a></sup> A second compiler, gccgo, is a <a href="/wiki/GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a> frontend.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span>[</span>9<span>]</span></a></sup><sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span>[</span>10<span>]</span></a></sup></p>
<p></p>
<div id="toc" class="toc">
<div id="toctitle">
<h2>Contents</h2>
</div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#History"><span class="tocnumber">1</span> <span class="toctext">History</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Language_design"><span class="tocnumber">2</span> <span class="toctext">Language design</span></a>
<ul>
<li class="toclevel-2 tocsection-3"><a href="#Syntax"><span class="tocnumber">2.1</span> <span class="toctext">Syntax</span></a></li>
<li class="toclevel-2 tocsection-4"><a href="#Types"><span class="tocnumber">2.2</span> <span class="toctext">Types</span></a></li>
<li class="toclevel-2 tocsection-5"><a href="#Package_system"><span class="tocnumber">2.3</span> <span class="toctext">Package system</span></a></li>
<li class="toclevel-2 tocsection-6"><a href="#Concurrency:_goroutines.2C_channels.2C_and_select"><span class="tocnumber">2.4</span> <span class="toctext">Concurrency: goroutines, channels, and select</span></a>
<ul>
<li class="toclevel-3 tocsection-7"><a href="#Race_condition_safety"><span class="tocnumber">2.4.1</span> <span class="toctext">Race condition safety</span></a></li>
</ul>
</li>
<li class="toclevel-2 tocsection-8"><a href="#Interface_system"><span class="tocnumber">2.5</span> <span class="toctext">Interface system</span></a></li>
<li class="toclevel-2 tocsection-9"><a href="#Omissions"><span class="tocnumber">2.6</span> <span class="toctext">Omissions</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-10"><a href="#Conventions_and_code_style"><span class="tocnumber">3</span> <span class="toctext">Conventions and code style</span></a></li>
<li class="toclevel-1 tocsection-11"><a href="#Language_tools"><span class="tocnumber">4</span> <span class="toctext">Language tools</span></a></li>
<li class="toclevel-1 tocsection-12"><a href="#Examples"><span class="tocnumber">5</span> <span class="toctext">Examples</span></a>
<ul>
<li class="toclevel-2 tocsection-13"><a href="#Hello_world"><span class="tocnumber">5.1</span> <span class="toctext">Hello world</span></a></li>
<li class="toclevel-2 tocsection-14"><a href="#Echo"><span class="tocnumber">5.2</span> <span class="toctext">Echo</span></a></li>
<li class="toclevel-2 tocsection-15"><a href="#File_Read"><span class="tocnumber">5.3</span> <span class="toctext">File Read</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-16"><a href="#Notable_users"><span class="tocnumber">6</span> <span class="toctext">Notable users</span></a></li>
<li class="toclevel-1 tocsection-17"><a href="#Libraries"><span class="tocnumber">7</span> <span class="toctext">Libraries</span></a></li>
<li class="toclevel-1 tocsection-18"><a href="#Community_and_conferences"><span class="tocnumber">8</span> <span class="toctext">Community and conferences</span></a></li>
<li class="toclevel-1 tocsection-19"><a href="#Reception"><span class="tocnumber">9</span> <span class="toctext">Reception</span></a></li>
<li class="toclevel-1 tocsection-20"><a href="#Mascot"><span class="tocnumber">10</span> <span class="toctext">Mascot</span></a></li>
<li class="toclevel-1 tocsection-21"><a href="#Naming_dispute"><span class="tocnumber">11</span> <span class="toctext">Naming dispute</span></a></li>
<li class="toclevel-1 tocsection-22"><a href="#See_also"><span class="tocnumber">12</span> <span class="toctext">See also</span></a></li>
<li class="toclevel-1 tocsection-23"><a href="#Notes"><span class="tocnumber">13</span> <span class="toctext">Notes</span></a></li>
<li class="toclevel-1 tocsection-24"><a href="#References"><span class="tocnumber">14</span> <span class="toctext">References</span></a></li>
<li class="toclevel-1 tocsection-25"><a href="#External_links"><span class="tocnumber">15</span> <span class="toctext">External links</span></a></li>
</ul>
</div>
<p></p>
<h2><span class="mw-headline" id="History">History</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=1" title="Edit section: History">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Ken Thompson states that, initially, Go was purely an experimental project. Referring to himself along with the other original authors of Go, he states:<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span>[</span>11<span>]</span></a></sup></p>
<blockquote class="templatequote">
<p>When the three of us [Thompson, Rob Pike, and Robert Griesemer] got started, it was pure research. The three of us got together and decided that we hated <a href="/wiki/C%2B%2B" title="C++">C++</a>. [laughter] ... [Returning to Go,] we started off with the idea that all three of us had to be talked into every feature in the language, so there was no extraneous garbage put into the language for any reason.</p>
</blockquote>
<p>The history of the language before its first release, back to 2007, is covered in the language's FAQ.<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span>[</span>12<span>]</span></a></sup></p>
<h2><span class="mw-headline" id="Language_design">Language design</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=2" title="Edit section: Language design">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Go is recognizably in the tradition of C, but makes many changes aimed at conciseness, simplicity, and safety. The following is a brief overview of the features which define Go (for more information see the <a rel="nofollow" class="external text" href="http://golang.org/ref/spec">language specification</a>):</p>
<ul>
<li>A syntax and environment adopting patterns more common in <a href="/wiki/Dynamic_programming_language" title="Dynamic programming language">dynamic languages</a>:<sup id="cite_ref-go_lang_video_2009_13-0" class="reference"><a href="#cite_note-go_lang_video_2009-13"><span>[</span>13<span>]</span></a></sup>
<ul>
<li>Concise variable declaration and initialization through <a href="/wiki/Type_inference" title="Type inference">type inference</a> (<code>x := 0</code> not <code>int x = 0;</code>).</li>
<li>Fast compilation times.<sup id="cite_ref-techtalk-compiling_14-0" class="reference"><a href="#cite_note-techtalk-compiling-14"><span>[</span>14<span>]</span></a></sup></li>
<li>Remote package management (<code>go get</code>)<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span>[</span>15<span>]</span></a></sup> and online package documentation.<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span>[</span>16<span>]</span></a></sup></li>
</ul>
</li>
<li>Distinctive approaches to particular problems.
<ul>
<li>Built-in concurrency primitives: <a href="/wiki/Light-weight_process" title="Light-weight process">light-weight processes</a> (goroutines), <a href="/wiki/Channel_(programming)" title="Channel (programming)">channels</a>, and the <code>select</code> statement.</li>
<li>An <a href="/wiki/Protocol_(object-oriented_programming)" title="Protocol (object-oriented programming)">interface</a> system in place of <a href="/wiki/Virtual_inheritance" title="Virtual inheritance">virtual inheritance</a>, and type embedding instead of non-virtual inheritance.</li>
<li>A toolchain that, by default, produces <a href="/wiki/Static_library" title="Static library">statically linked</a> native binaries without external dependencies.</li>
</ul>
</li>
<li>A desire to keep the <a rel="nofollow" class="external text" href="http://golang.org/ref/spec">language specification</a> simple enough to hold in a programmer's head,<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span>[</span>17<span>]</span></a></sup><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span>[</span>18<span>]</span></a></sup> in part by omitting features common to similar languages:
<ul>
<li>no <a href="/wiki/Type_inheritance" title="Type inheritance" class="mw-redirect">type inheritance</a></li>
<li>no <a href="/wiki/Method_overloading" title="Method overloading" class="mw-redirect">method</a> or <a href="/wiki/Operator_overloading" title="Operator overloading">operator overloading</a></li>
<li>no <a href="/wiki/Circular_dependencies" title="Circular dependencies" class="mw-redirect">circular dependencies</a> among packages</li>
<li>no <a href="/wiki/Pointer_arithmetic" title="Pointer arithmetic" class="mw-redirect">pointer arithmetic</a></li>
<li>no <a href="/wiki/Assertion_(computing)" title="Assertion (computing)" class="mw-redirect">assertions</a></li>
<li>no <a href="/wiki/Generic_programming" title="Generic programming">generic programming</a></li>
</ul>
</li>
</ul>
<h3><span class="mw-headline" id="Syntax">Syntax</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=3" title="Edit section: Syntax">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Go's syntax includes changes from C aimed at keeping code concise and readable. The programmer needn't specify the types of expressions, allowing just <code>i := 3</code> or <code>s := "some words"</code> to replace C's <code>int i = 3;</code> or <code>char* s = "some words";</code>. Semicolons at the end of lines aren't required. Functions may return multiple, named values, and returning a <code>result, err</code> pair is the conventional way a function indicates an error to its caller in Go.<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span>[</span>a<span>]</span></a></sup> Go adds literal syntaxes for initializing struct parameters by name, and for initializing maps and slices. As an alternative to C's three-statement <code>for</code> loop, Go's <code>range</code> expressions allow concise iteration over arrays, slices, strings, and maps.</p>
<h3><span class="mw-headline" id="Types">Types</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=4" title="Edit section: Types">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Go adds some basic types not present in C for safety and convenience:</p>
<ul>
<li><i>Slices</i> (written <code>[]<i>type</i></code>) point into an array of objects in memory, storing a pointer to the start of the slice, a length, and a <i>capacity</i> specifying when new memory needs to be allocated to expand the array. Slice contents are passed by reference, and their contents are always mutable.</li>
<li>Go's immutable <code>string</code> type typically holds UTF-8 text (though it can hold arbitrary bytes as well).</li>
<li><code>map[<i>keytype</i>]<i>valtype</i></code> provides a hashtable.</li>
<li>Go also adds <i>channel types</i>, which support concurrency and are discussed below, and <i>interfaces</i>, which replace virtual inheritance and are discussed in Interface system section.</li>
</ul>
<p>Structurally, Go's type system has a few differences from C and most C derivatives. Unlike C <code>typedef</code>s, Go's named <code>type</code>s are not aliases for each other, and rules limit when different types can be assigned to each other without explicit conversion.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span>[</span>19<span>]</span></a></sup> Unlike in C, conversions between number types are explicit; to ensure that doesn't create verbose conversion-heavy code, numeric constants in Go represent abstract, untyped numbers.<sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span>[</span>20<span>]</span></a></sup> Finally, in place of non-virtual inheritance, Go has a feature called <i>type embedding</i> in which one object can contain others and pick up their methods.</p>
<h3><span class="mw-headline" id="Package_system">Package system</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=5" title="Edit section: Package system">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>In Go's package system, each package has a path (e.g., <code>"compress/bzip2"</code> or <code>"code.google.com/p/go.net/html"</code>) and a name (e.g., <code>bzip2</code> or <code>html</code>). References to other packages' definitions must <i>always</i> be prefixed with the other package's name, and only the <i>capitalized</i> names from other modules are accessible: <code>io.Reader</code> is public but <code>bzip2.reader</code> is not.<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span>[</span>21<span>]</span></a></sup> The <code>go get</code> command can retrieve packages stored in a remote repository such as Github or Google Code, and package paths often look like partial URLs for compatibility.<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span>[</span>22<span>]</span></a></sup></p>
<h3><span class="mw-headline" id="Concurrency:_goroutines.2C_channels.2C_and_select">Concurrency: goroutines, channels, and <code>select</code></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=6" title="Edit section: Concurrency: goroutines, channels, and select">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Go provides facilities for writing concurrent programs that share state by communicating.<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span>[</span>23<span>]</span></a></sup><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span>[</span>24<span>]</span></a></sup><sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span>[</span>25<span>]</span></a></sup> Concurrency refers not only to <a href="/wiki/Multithreading_(software)" title="Multithreading (software)" class="mw-redirect">multithreading</a> and CPU parallelism, which Go supports, but also to <a href="/wiki/Asynchronous_I/O" title="Asynchronous I/O">asynchrony</a>: letting slow operations like a database or network-read run while the program does other work, as is common in event-based servers.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span>[</span>26<span>]</span></a></sup></p>
<p>Go's concurrency-related syntax and types include:</p>
<ul>
<li>The <code>go</code> statement, <code>go <i>func()</i></code>, starts a function in a new <a href="/wiki/Light-weight_process" title="Light-weight process">light-weight process</a>, or <i>goroutine</i></li>
<li><i>Channel types</i>, <code>chan <i>type</i></code>, provide a type-safe, synchronized, optionally buffered channels between goroutines, and are useful mostly with two other facilities:
<ul>
<li>The <i>send statement</i>, <code><i>ch</i> <- <i>x</i></code> sends <code><i>x</i></code> over <code><i>ch</i></code></li>
<li>The <i>receive operator</i>, <code><- <i>ch</i></code> receives a value from <code><i>ch</i></code></li>
<li>Both operations <a href="/wiki/Blocking_(computing)" title="Blocking (computing)">block</a> until the other goroutine is ready to communicate</li>
</ul>
</li>
<li>The <code>select</code> statement uses a <code>switch</code>-like syntax to wait for communication on any of a set of channels<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span>[</span>27<span>]</span></a></sup></li>
</ul>
<p>From these tools one can build concurrent constructs like worker pools, pipelines (in which, say, a file is decompressed and parsed as it downloads), background calls with timeout, "fan-out" parallel calls to a set of services, and others.<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span>[</span>28<span>]</span></a></sup> Channels have also found uses further from the usual notion of interprocess communication, like serving as a concurrency-safe list of recycled buffers,<sup id="cite_ref-30" class="reference"><a href="#cite_note-30"><span>[</span>29<span>]</span></a></sup> implementing coroutines (which helped inspire the name <i>goroutine</i>),<sup id="cite_ref-31" class="reference"><a href="#cite_note-31"><span>[</span>30<span>]</span></a></sup> and implementing iterators.<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span>[</span>31<span>]</span></a></sup></p>
<p>While the communicating-processes model is favored in Go, it isn't the only one: memory can be shared across goroutines (see below), and the standard <code>sync</code> module provides locks and other primitives.<sup id="cite_ref-33" class="reference"><a href="#cite_note-33"><span>[</span>32<span>]</span></a></sup></p>
<h4><span class="mw-headline" id="Race_condition_safety">Race condition safety</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=7" title="Edit section: Race condition safety">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
<p>There are no restrictions on how goroutines access shared data, making <a href="/wiki/Race_conditions" title="Race conditions" class="mw-redirect">race conditions</a> possible. Specifically, unless a program explicitly synchronizes via channels or other means, writes from one goroutine might be partly, entirely, or not at all visible to another, often with no guarantees about ordering of writes.<sup id="cite_ref-memmodel_34-0" class="reference"><a href="#cite_note-memmodel-34"><span>[</span>33<span>]</span></a></sup> Furthermore, Go's <i>internal data structures</i> like interface values, slice headers, and string headers are not immune to race conditions, so type and memory safety can be violated in multithreaded programs that modify shared instances of those types without synchronization.<sup id="cite_ref-35" class="reference"><a href="#cite_note-35"><span>[</span>34<span>]</span></a></sup><sup id="cite_ref-SPLASH2012_36-0" class="reference"><a href="#cite_note-SPLASH2012-36"><span>[</span>35<span>]</span></a></sup></p>
<p>Idiomatic Go minimizes sharing of data (and thus potential race conditions) by communicating over channels, and a race-condition tester is included in the standard distribution to help catch unsafe behavior. Still, it is important to realize that while Go provides <i>building blocks</i> that can be used to write correct, comprehensible concurrent code, arbitrary code isn't <i>guaranteed</i> to be safe.</p>
<p>Some concurrency-related structural conventions of Go (<a href="/wiki/Channel_(programming)" title="Channel (programming)">channels</a> and alternative channel inputs) are derived from <a href="/wiki/C._A._R._Hoare" title="C. A. R. Hoare" class="mw-redirect">Tony Hoare's</a> <a href="/wiki/Communicating_sequential_processes" title="Communicating sequential processes">communicating sequential processes</a> model. Unlike previous concurrent programming languages such as <a href="/wiki/Occam_(programming_language)" title="Occam (programming language)">occam</a> or <a href="/wiki/Limbo_(programming_language)" title="Limbo (programming language)">Limbo</a> (a language on which Go co-designer Rob Pike worked<sup id="cite_ref-37" class="reference"><a href="#cite_note-37"><span>[</span>36<span>]</span></a></sup>), Go does not provide any built-in notion of safe or verifiable concurrency.<sup id="cite_ref-memmodel_34-1" class="reference"><a href="#cite_note-memmodel-34"><span>[</span>33<span>]</span></a></sup></p>
<h3><span class="mw-headline" id="Interface_system">Interface system</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=8" title="Edit section: Interface system">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>In place of <a href="/wiki/Virtual_inheritance" title="Virtual inheritance">virtual inheritance</a>, Go uses <i><a href="/wiki/Protocol_(object-oriented_programming)" title="Protocol (object-oriented programming)">interfaces</a></i>. An interface declaration is nothing but a list of required methods: for example, implementing <code>io.Reader</code> requires a <code>Read</code> method that takes a <code>[]byte</code> and returns a count of bytes read and any error.<sup id="cite_ref-38" class="reference"><a href="#cite_note-38"><span>[</span>37<span>]</span></a></sup> Code calling <code>Read</code> needn't know whether it's reading from an HTTP connection, a file, an in-memory buffer, or any other source.</p>
<p>Go's standard library defines interfaces for a number of concepts: <a rel="nofollow" class="external text" href="http://golang.org/pkg/io/#Reader">input sources</a> and <a rel="nofollow" class="external text" href="http://golang.org/pkg/io/#Writer">output sinks,</a> <a rel="nofollow" class="external text" href="http://golang.org/pkg/sort/#Interface">sortable collections,</a> <a rel="nofollow" class="external text" href="http://golang.org/pkg/fmt/#Stringer">objects printable as strings,</a> <a rel="nofollow" class="external text" href="http://golang.org/pkg/hash/#Hash">cryptographic hashes</a>, and so on.</p>
<p>Go types don't declare which interfaces they implement: having the required methods <i>is</i> implementing the interface. In formal language, Go's interface system provides <a href="/wiki/Structural_type_system" title="Structural type system">structural</a> rather than <a href="/wiki/Nominal_type_system" title="Nominal type system">nominal</a> typing.</p>
<p>The example below uses the <code>io.Reader</code> and <code>io.Writer</code> interfaces to test Go's implementation of <a href="/wiki/SHA-256" title="SHA-256" class="mw-redirect">SHA-256</a> on a standard test input, 1,000,000 repeats of the character "a". <code>RepeatByte</code> implements an <code>io.Reader</code> yielding an infinite stream of repeats of a byte, similar to Unix <code>/dev/zero</code>. The <code>main()</code> function uses <code>RepeatByte</code> to stream a million repeats of "a" into the hash function, then prints the result, which matches the expected value published online.<sup id="cite_ref-39" class="reference"><a href="#cite_note-39"><span>[</span>38<span>]</span></a></sup> Even though both reader and writer interfaces are needed to make this work, the code needn't mention either; the compiler infers what types implement what interfaces:</p>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr">
<div class="go source-go">
<pre class="de1">
<span class="kw1">package</span> main
<span class="kw1">import</span> <span class="sy1">(</span>
<span class="st0">"fmt"</span>
<span class="st0">"io"</span>
<span class="st0">"crypto/sha256"</span>
<span class="sy1">)</span>
<span class="kw1">type</span> RepeatByte <span class="kw4">byte</span>
<span class="kw4">func</span> <span class="sy1">(</span>r RepeatByte<span class="sy1">)</span> Read<span class="sy1">(</span>p <span class="sy1">[]</span><span class="kw4">byte</span><span class="sy1">)</span> <span class="sy1">(</span>n <span class="kw4">int</span><span class="sy1">,</span> err error<span class="sy1">)</span> <span class="sy1">{</span>
<span class="kw1">for</span> <span class="nu2">i</span> <span class="sy2">:=</span> <span class="kw1">range</span> p <span class="sy1">{</span>
p<span class="sy1">[</span><span class="nu2">i</span><span class="sy1">]</span> <span class="sy2">=</span> <span class="kw4">byte</span><span class="sy1">(</span>r<span class="sy1">)</span>
<span class="sy1">}</span>
<span class="kw1">return</span> <span class="kw3">len</span><span class="sy1">(</span>p<span class="sy1">),</span> <span class="kw2">nil</span>
<span class="sy1">}</span>
<span class="kw4">func</span> main<span class="sy1">()</span> <span class="sy1">{</span>
testStream <span class="sy2">:=</span> RepeatByte<span class="sy1">(</span><span class="st0">'a'</span><span class="sy1">)</span>
hasher <span class="sy2">:=</span> sha256<span class="sy3">.</span>New<span class="sy1">()</span>
io<span class="sy3">.</span>CopyN<span class="sy1">(</span>hasher<span class="sy1">,</span> testStream<span class="sy1">,</span> <span class="nu0">1000000</span><span class="sy1">)</span>
fmt<span class="sy3">.</span>Printf<span class="sy1">(</span><span class="st0">"%x"</span><span class="sy1">,</span> hasher<span class="sy3">.</span>Sum<span class="sy1">(</span><span class="kw2">nil</span><span class="sy1">))</span>
<span class="sy1">}</span>
</pre></div>
</div>
<p>(<a rel="nofollow" class="external text" href="http://play.golang.org/p/MIaP4AXV_G">Run or edit this example online.</a>)</p>
<p>Also note <code>type RepeatByte</code> is defined as a <code>byte</code>, not a <code>struct</code>. Named types in Go needn't be <code>struct</code>s, and any named type can have methods defined, satisfy interfaces, and act, for practical purposes, as objects; the standard library, for example, stores IP addresses in byte slices.<sup id="cite_ref-40" class="reference"><a href="#cite_note-40"><span>[</span>39<span>]</span></a></sup></p>
<p>Besides calling methods via interfaces, Go allows converting interface values to other types with a run-time type check. The language constructs to do so are the <i>type assertion</i>,<sup id="cite_ref-41" class="reference"><a href="#cite_note-41"><span>[</span>40<span>]</span></a></sup> which checks against a single potential type, and the <i>type switch</i>,<sup id="cite_ref-42" class="reference"><a href="#cite_note-42"><span>[</span>41<span>]</span></a></sup> which checks against multiple types.</p>
<p><code>interface{}</code>, the <i>empty interface</i>, is an important corner case because it can refer to an item of <i>any</i> concrete type, including primitive types like <code>string</code>. Code using the empty interface can't simply call methods (or built-in operators) on the referred-to object, but it can store the <code>interface{}</code> value, try to convert it to a more useful type via a type assertion or type switch, or inspect it with Go's <code>reflect</code> package.<sup id="cite_ref-43" class="reference"><a href="#cite_note-43"><span>[</span>42<span>]</span></a></sup> Because <code>interface{}</code> can refer to any value, it's a limited way to escape the restrictions of static typing, like <code>void*</code> in C but with additional run-time type checks.</p>
<p>Interface values are stored in memory as a pointer to data and a second pointer to run-time type information.<sup id="cite_ref-44" class="reference"><a href="#cite_note-44"><span>[</span>43<span>]</span></a></sup> Like other pointers in Go, interface values are <code>nil</code> if uninitialized.<sup id="cite_ref-45" class="reference"><a href="#cite_note-45"><span>[</span>44<span>]</span></a></sup> Unlike in environments like Java's virtual machine, there is no object header; the run-time type information is only attached to interface values. So, the system imposes no per-object memory overhead for objects not accessed via interface, similar to C <code>struct</code>s or C# <code>ValueType</code>s.</p>
<p>Go does not have <a href="/wiki/Interface_inheritance" title="Interface inheritance" class="mw-redirect">interface inheritance</a>, but one interface type can <i>embed</i> another; then the embedding interface requires all of the methods required by the embedded interface.<sup id="cite_ref-46" class="reference"><a href="#cite_note-46"><span>[</span>45<span>]</span></a></sup></p>
<h3><span class="mw-headline" id="Omissions">Omissions</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=9" title="Edit section: Omissions">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Go deliberately omits certain features common in other languages, including <a href="/wiki/Generic_programming" title="Generic programming">generic programming</a>, assertions, pointer arithmetic, and inheritance. After initially omitting <a href="/wiki/Exception_handling" title="Exception handling">exceptions</a>, the language added the <code>panic</code>/<code>recover</code> mechanism, but it is only meant for rare circumstances.<sup id="cite_ref-47" class="reference"><a href="#cite_note-47"><span>[</span>46<span>]</span></a></sup><sup id="cite_ref-48" class="reference"><a href="#cite_note-48"><span>[</span>47<span>]</span></a></sup><sup id="cite_ref-49" class="reference"><a href="#cite_note-49"><span>[</span>48<span>]</span></a></sup></p>
<p>The Go authors express an openness to generic programming, explicitly argue against assertions and pointer arithmetic, while defending the choice to omit type inheritance as giving a more useful language, encouraging heavy use of <a href="/wiki/Protocol_(object-oriented_programming)" title="Protocol (object-oriented programming)">interfaces</a> instead.<sup id="cite_ref-langfaq_2-2" class="reference"><a href="#cite_note-langfaq-2"><span>[</span>2<span>]</span></a></sup></p>
<h2><span class="mw-headline" id="Conventions_and_code_style">Conventions and code style</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=10" title="Edit section: Conventions and code style">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>The Go authors and community put substantial effort into molding the style and design of Go programs:</p>
<ul>
<li>Indentation, spacing, and other surface-level details of code are automatically standardized by the <code>go fmt</code> tool. <code>go vet</code> and <code>golint</code> do additional checking automatically.</li>
<li>Tools and libraries distributed with Go suggest standard approaches to things like API documentation (<code>godoc</code><sup id="cite_ref-50" class="reference"><a href="#cite_note-50"><span>[</span>49<span>]</span></a></sup>), testing (<code>go test</code>), building (<code>go build</code>), package management (<code>go get</code>), and so on.</li>
<li>Syntax rules require things that are optional in other languages, for example by banning cyclic dependencies, unused variables or imports, and implicit type conversions.</li>
<li>The <i>omission</i> of certain features (for example, functional-programming shortcuts like <code>map</code> and C++-style <code>try</code>/<code>finally</code> blocks) tends to encourage a particular explicit, concrete, and imperative programming style.</li>
<li>Core developers write extensively about Go idioms, style, and philosophy, in <a rel="nofollow" class="external text" href="http://golang.org/doc/effective_go.html">the Effective Go document</a> and <a rel="nofollow" class="external text" href="https://code.google.com/p/go-wiki/wiki/CodeReviewComments">code review comments reference</a>, <a rel="nofollow" class="external text" href="http://talks.golang.org/">presentations</a>, <a rel="nofollow" class="external text" href="http://commandcenter.blogspot.com/2012/06/less-is-exponentially-more.html">blog posts</a>, and <a rel="nofollow" class="external text" href="https://groups.google.com/d/msg/golang-dev/CGGiLKunggo/2z051XlQO1EJ">public mailing list messages</a>.</li>
</ul>
<p>When adapting to the Go ecosystem after working in other languages, differences in style and approach can be as important as low-level language and library differences.</p>
<h2><span class="mw-headline" id="Language_tools">Language tools</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=11" title="Edit section: Language tools">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Go includes the same sort of debugging, testing, and code-vetting tools as many language distributions. The Go distribution includes <code>go vet</code>, which analyzes code searching for common stylistic problems and mistakes. A profiler, unit testing tool, <code>gdb</code> debugging support, and a race condition tester are also in the distribution. The Go distribution includes its own build system, which requires only information in the Go files themselves, no separate build files.</p>
<p>There is an ecosystem of third-party tools that add to the standard distribution, such as <code>gocode</code>, which enables code autocompletion in many text editors, <code>goimports</code> (by a Go team member), which automatically adds/removes package imports as needed, <code>errcheck</code>, which detects code that might unintentionally ignore errors, and more. Plugins exist to add language support in widely used text editors, and at least one <a href="/wiki/Integrated_development_environment" title="Integrated development environment">IDE</a>, <a rel="nofollow" class="external text" href="https://github.com/visualfc/liteide">LiteIDE</a>, targets Go in particular.</p>
<h2><span class="mw-headline" id="Examples">Examples</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=12" title="Edit section: Examples">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<h3><span class="mw-headline" id="Hello_world">Hello world</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=13" title="Edit section: Hello world">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Here is a <a href="/wiki/Hello_world_program" title="Hello world program" class="mw-redirect">Hello world program</a> in Go:</p>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr">
<div class="go source-go">
<pre class="de1">
<span class="kw1">package</span> main
<span class="kw1">import</span> <span class="st0">"fmt"</span>
<span class="kw4">func</span> main<span class="sy1">()</span> <span class="sy1">{</span>
fmt<span class="sy3">.</span>Println<span class="sy1">(</span><span class="st0">"Hello, World"</span><span class="sy1">)</span>
<span class="sy1">}</span>
</pre></div>
</div>
<p>(<a rel="nofollow" class="external text" href="http://play.golang.org/p/6wn73kqMxi">Run or edit this example online.</a>)</p>
<h3><span class="mw-headline" id="Echo">Echo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=14" title="Edit section: Echo">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>This imitates the Unix <a href="/wiki/Echo_(command)" title="Echo (command)">echo command</a> in Go:<sup id="cite_ref-51" class="reference"><a href="#cite_note-51"><span>[</span>50<span>]</span></a></sup></p>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr">
<div class="go source-go">
<pre class="de1">
<span class="kw1">package</span> main
<span class="kw1">import</span> <span class="sy1">(</span>
<span class="st0">"flag"</span>
<span class="st0">"fmt"</span>
<span class="st0">"strings"</span>
<span class="sy1">)</span>
<span class="kw4">func</span> main<span class="sy1">()</span> <span class="sy1">{</span>
<span class="kw1">var</span> omitNewline <span class="kw4">bool</span>
flag<span class="sy3">.</span>BoolVar<span class="sy1">(</span>&omitNewline<span class="sy1">,</span> <span class="st0">"n"</span><span class="sy1">,</span> <span class="kw2">false</span><span class="sy1">,</span> <span class="st0">"don't print final newline"</span><span class="sy1">)</span>
flag<span class="sy3">.</span><span class="me1">Parse</span><span class="sy1">()</span> <span class="co1">// Scans the arg list and sets up flags.</span>
str <span class="sy2">:=</span> strings<span class="sy3">.</span><span class="me1">Join</span><span class="sy1">(</span>flag<span class="sy3">.</span><span class="me1">Args</span><span class="sy1">(),</span> <span class="st0">" "</span><span class="sy1">)</span>
<span class="kw1">if</span> omitNewline <span class="sy1">{</span>
fmt<span class="sy3">.</span>Print<span class="sy1">(</span>str<span class="sy1">)</span>
<span class="sy1">}</span> <span class="kw1">else</span> <span class="sy1">{</span>
fmt<span class="sy3">.</span>Println<span class="sy1">(</span>str<span class="sy1">)</span>
<span class="sy1">}</span>
<span class="sy1">}</span>
</pre></div>
</div>
<h3><span class="mw-headline" id="File_Read">File Read</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=15" title="Edit section: File Read">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr">
<div class="go source-go">
<pre class="de1">
<span class="co1">// Reading and writing files are basic tasks needed for</span>
<span class="co1">// many Go programs. First we'll look at some examples of</span>
<span class="co1">// reading files.</span>
<span class="kw1">package</span> main
<span class="kw1">import</span> <span class="sy1">(</span>
<span class="st0">"bufio"</span>
<span class="st0">"fmt"</span>
<span class="st0">"io"</span>
<span class="st0">"io/ioutil"</span>
<span class="st0">"os"</span>
<span class="sy1">)</span>
<span class="co1">// Reading files requires checking most calls for errors.</span>
<span class="co1">// This helper will streamline our error checks below.</span>
<span class="kw4">func</span> check<span class="sy1">(</span>e error<span class="sy1">)</span> <span class="sy1">{</span>
<span class="kw1">if</span> e <span class="sy2">!=</span> <span class="kw2">nil</span> <span class="sy1">{</span>
<span class="kw3">panic</span><span class="sy1">(</span>e<span class="sy1">)</span>
<span class="sy1">}</span>
<span class="sy1">}</span>
<span class="kw4">func</span> main<span class="sy1">()</span> <span class="sy1">{</span>
<span class="co1">// Perhaps the most basic file reading task is</span>
<span class="co1">// slurping a file's entire contents into memory.</span>
dat<span class="sy1">,</span> err <span class="sy2">:=</span> ioutil<span class="sy3">.</span><span class="me1">ReadFile</span><span class="sy1">(</span><span class="st0">"/tmp/dat"</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
fmt<span class="sy3">.</span>Print<span class="sy1">(</span><span class="kw4">string</span><span class="sy1">(</span>dat<span class="sy1">))</span>
<span class="co1">// You'll often want more control over how and what</span>
<span class="co1">// parts of a file are read. For these tasks, start</span>
<span class="co1">// by `Open`ing a file to obtain an `os.File` value.</span>
f<span class="sy1">,</span> err <span class="sy2">:=</span> os<span class="sy3">.</span><span class="me1">Open</span><span class="sy1">(</span><span class="st0">"/tmp/dat"</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
<span class="co1">// Read some bytes from the beginning of the file.</span>
<span class="co1">// Allow up to 5 to be read but also note how many</span>
<span class="co1">// actually were read.</span>
b1 <span class="sy2">:=</span> <span class="kw3">make</span><span class="sy1">([]</span><span class="kw4">byte</span><span class="sy1">,</span> <span class="nu0">5</span><span class="sy1">)</span>
n1<span class="sy1">,</span> err <span class="sy2">:=</span> f<span class="sy3">.</span>Read<span class="sy1">(</span>b1<span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
fmt<span class="sy3">.</span>Printf<span class="sy1">(</span><span class="st0">"%d bytes: %s<span class="es1">\n</span>"</span><span class="sy1">,</span> n1<span class="sy1">,</span> <span class="kw4">string</span><span class="sy1">(</span>b1<span class="sy1">))</span>
<span class="co1">// You can also `Seek` to a known location in the file</span>
<span class="co1">// and `Read` from there.</span>
o2<span class="sy1">,</span> err <span class="sy2">:=</span> f<span class="sy3">.</span>Seek<span class="sy1">(</span><span class="nu0">6</span><span class="sy1">,</span> <span class="nu0">0</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
b2 <span class="sy2">:=</span> <span class="kw3">make</span><span class="sy1">([]</span><span class="kw4">byte</span><span class="sy1">,</span> <span class="nu0">2</span><span class="sy1">)</span>
n2<span class="sy1">,</span> err <span class="sy2">:=</span> f<span class="sy3">.</span>Read<span class="sy1">(</span>b2<span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
fmt<span class="sy3">.</span>Printf<span class="sy1">(</span><span class="st0">"%d bytes @ %d: %s<span class="es1">\n</span>"</span><span class="sy1">,</span> n2<span class="sy1">,</span> o2<span class="sy1">,</span> <span class="kw4">string</span><span class="sy1">(</span>b2<span class="sy1">))</span>
<span class="co1">// The `io` package provides some functions that may</span>
<span class="co1">// be helpful for file reading. For example, reads</span>
<span class="co1">// like the ones above can be more robustly</span>
<span class="co1">// implemented with `ReadAtLeast`.</span>
o3<span class="sy1">,</span> err <span class="sy2">:=</span> f<span class="sy3">.</span>Seek<span class="sy1">(</span><span class="nu0">6</span><span class="sy1">,</span> <span class="nu0">0</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
b3 <span class="sy2">:=</span> <span class="kw3">make</span><span class="sy1">([]</span><span class="kw4">byte</span><span class="sy1">,</span> <span class="nu0">2</span><span class="sy1">)</span>
n3<span class="sy1">,</span> err <span class="sy2">:=</span> io<span class="sy3">.</span>ReadAtLeast<span class="sy1">(</span>f<span class="sy1">,</span> b3<span class="sy1">,</span> <span class="nu0">2</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
fmt<span class="sy3">.</span>Printf<span class="sy1">(</span><span class="st0">"%d bytes @ %d: %s<span class="es1">\n</span>"</span><span class="sy1">,</span> n3<span class="sy1">,</span> o3<span class="sy1">,</span> <span class="kw4">string</span><span class="sy1">(</span>b3<span class="sy1">))</span>
<span class="co1">// There is no built-in rewind, but `Seek(0, 0)`</span>
<span class="co1">// accomplishes this.</span>
_<span class="sy1">,</span> err <span class="sy2">=</span> f<span class="sy3">.</span>Seek<span class="sy1">(</span><span class="nu0">0</span><span class="sy1">,</span> <span class="nu0">0</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
<span class="co1">// The `bufio` package implements a buffered</span>
<span class="co1">// reader that may be useful both for its efficiency</span>
<span class="co1">// with many small reads and because of the additional</span>
<span class="co1">// reading methods it provides.</span>
r4 <span class="sy2">:=</span> bufio<span class="sy3">.</span>NewReader<span class="sy1">(</span>f<span class="sy1">)</span>
b4<span class="sy1">,</span> err <span class="sy2">:=</span> r4<span class="sy3">.</span>Peek<span class="sy1">(</span><span class="nu0">5</span><span class="sy1">)</span>
check<span class="sy1">(</span>err<span class="sy1">)</span>
fmt<span class="sy3">.</span>Printf<span class="sy1">(</span><span class="st0">"5 bytes: %s<span class="es1">\n</span>"</span><span class="sy1">,</span> <span class="kw4">string</span><span class="sy1">(</span>b4<span class="sy1">))</span>
<span class="co1">// Close the file when you're done (usually this would</span>
<span class="co1">// be scheduled immediately after `Open`ing with</span>
<span class="co1">// `defer`).</span>
f<span class="sy3">.</span><span class="me1">Close</span><span class="sy1">()</span>
<span class="sy1">}</span>
</pre></div>
</div>
<p><sup id="cite_ref-52" class="reference"><a href="#cite_note-52"><span>[</span>51<span>]</span></a></sup><sup id="cite_ref-53" class="reference"><a href="#cite_note-53"><span>[</span>52<span>]</span></a></sup></p>
<h2><span class="mw-headline" id="Notable_users">Notable users</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=16" title="Edit section: Notable users">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Some notable <a href="/wiki/Open-source" title="Open-source" class="mw-redirect">open-source</a> applications in Go include:</p>
<ul>
<li><a href="/wiki/Docker_(software)" title="Docker (software)">Docker</a>, a set of tools for deploying <a href="/wiki/Linux" title="Linux">Linux</a> containers</li>
<li><a rel="nofollow" class="external text" href="https://github.com/flynn">Flynn</a>, a <a href="/wiki/Platform_as_a_service" title="Platform as a service">PaaS</a> powered by Docker</li>
<li><a href="/wiki/Juju_(software)" title="Juju (software)">Juju</a>, a service orchestration tool by <a href="/wiki/Canonical_Ltd." title="Canonical Ltd.">Canonical</a>, packagers of <a href="/wiki/Ubuntu_(operating_system)" title="Ubuntu (operating system)">Ubuntu</a> Linux</li>
<li><a rel="nofollow" class="external text" href="https://github.com/bitly/nsq">nsq</a>, a message queue by <a href="/wiki/Bitly" title="Bitly">bit.ly</a></li>
<li><a rel="nofollow" class="external text" href="http://xph.us/2011/04/13/introducing-doozer.html">Doozer</a>, a lock service by managed hosting provider <a href="/wiki/Heroku" title="Heroku">Heroku</a></li>
</ul>
<p>Other companies and sites using Go (generally together with other languages, not exclusively) include:<sup id="cite_ref-54" class="reference"><a href="#cite_note-54"><span>[</span>53<span>]</span></a></sup><sup id="cite_ref-55" class="reference"><a href="#cite_note-55"><span>[</span>54<span>]</span></a></sup></p>
<ul>
<li><a href="/wiki/Google" title="Google">Google</a>, for many projects, notably including download server dl.google.com<sup id="cite_ref-56" class="reference"><a href="#cite_note-56"><span>[</span>55<span>]</span></a></sup><sup id="cite_ref-57" class="reference"><a href="#cite_note-57"><span>[</span>56<span>]</span></a></sup><sup id="cite_ref-58" class="reference"><a href="#cite_note-58"><span>[</span>57<span>]</span></a></sup></li>
<li><a href="/wiki/Dropbox_(service)" title="Dropbox (service)">Dropbox</a>, migrated some of their critical components from Python to Go<sup id="cite_ref-59" class="reference"><a href="#cite_note-59"><span>[</span>58<span>]</span></a></sup></li>
<li><a href="/wiki/CloudFlare" title="CloudFlare">CloudFlare</a>, for their delta-coding proxy <a rel="nofollow" class="external text" href="https://www.cloudflare.com/railgun">Railgun</a>, their distributed DNS service, as well as tools for cryptography, logging, stream processing, and accessing SPDY sites.<sup id="cite_ref-60" class="reference"><a href="#cite_note-60"><span>[</span>59<span>]</span></a></sup><sup id="cite_ref-61" class="reference"><a href="#cite_note-61"><span>[</span>60<span>]</span></a></sup></li>
<li><a href="/wiki/SoundCloud" title="SoundCloud">SoundCloud</a>, for "dozens of systems"<sup id="cite_ref-62" class="reference"><a href="#cite_note-62"><span>[</span>61<span>]</span></a></sup></li>
<li>The <a href="/wiki/BBC" title="BBC">BBC</a>, in some games and internal projects</li>
<li><a href="/wiki/Novartis" title="Novartis">Novartis</a>, for an internal inventory system</li>
<li><a href="/wiki/Cloud_Foundry" title="Cloud Foundry">Cloud Foundry</a>, a <a href="/wiki/Platform_as_a_service" title="Platform as a service">platform as a service</a></li>
<li><a href="/wiki/CoreOS" title="CoreOS">CoreOS</a>, an operating system based on <a href="/wiki/Chrome_OS" title="Chrome OS">Chrome OS</a></li>
<li><a href="/wiki/MongoDB" title="MongoDB">MongoDB</a>, tools for administrating MongoDB instances</li>
</ul>
<h2><span class="mw-headline" id="Libraries">Libraries</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=17" title="Edit section: Libraries">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Go's open-source libraries include:</p>
<ul>
<li>Go's <a rel="nofollow" class="external text" href="http://golang.org/pkg">standard library</a>, which covers a lot of fundamental functionality:
<ul>
<li>Algorithms: compression, cryptography, sorting, math, indexing, and text and string manipulation.</li>
<li>External interfaces: I/O, network clients and servers, parsing and writing common formats, running system calls, and interacting with C code.</li>
<li>Development tools: reflection, runtime control, debugging, profiling, unit testing, synchronization, and parsing Go.</li>
</ul>
</li>
<li>Third-party libraries with more specialized tools:
<ul>
<li>Web toolkits, including <a rel="nofollow" class="external text" href="http://www.gorillatoolkit.org/">the Gorilla Web Toolkit</a>, <a rel="nofollow" class="external text" href="http://revel.github.io/">Revel</a>, and <a rel="nofollow" class="external text" href="https://github.com/stretchr/goweb">goweb</a></li>
<li>Database, stream, and caching tools, including <a rel="nofollow" class="external text" href="https://github.com/golang/groupcache">groupcache</a> and <a rel="nofollow" class="external text" href="https://github.com/cznic/kv">kv</a> and <a rel="nofollow" class="external text" href="https://github.com/cznic/ql">ql</a></li>
<li>Parsers for common formats, such as <a rel="nofollow" class="external text" href="https://code.google.com/p/go.net/html">HTML</a>, <a rel="nofollow" class="external text" href="https://github.com/bitly/go-simplejson">JSON</a>, and Google <a rel="nofollow" class="external text" href="https://code.google.com/p/goprotobuf/">Protocol Buffers</a></li>
<li>Protocol implementations, such as <a rel="nofollow" class="external text" href="https://code.google.com/p/go.crypto/ssh">ssh</a>, <a rel="nofollow" class="external text" href="https://github.com/amahi/spdy">SPDY</a>, and <a rel="nofollow" class="external text" href="https://code.google.com/p/go.net/websocket">websocket</a></li>
<li>Database drivers, such as <a rel="nofollow" class="external text" href="https://code.google.com/p/go-sqlite/">sqlite3</a>, <a rel="nofollow" class="external text" href="https://github.com/go-sql-driver/mysql">mysql</a>, and <a rel="nofollow" class="external text" href="https://github.com/garyburd/redigo/">redis</a></li>
<li>Bindings to C libraries, such as <a rel="nofollow" class="external text" href="https://github.com/youtube/vitess/tree/master/go/cgzip">cgzip</a>, <a rel="nofollow" class="external text" href="https://github.com/niemeyer/qml">qml</a>, and <a rel="nofollow" class="external text" href="https://github.com/mattn/go-gtk">GTK</a></li>
<li>Specialized tools like <a rel="nofollow" class="external text" href="https://code.google.com/p/biogo/">biogo</a> for bioinformatics, <a rel="nofollow" class="external text" href="https://github.com/soniakeys/meeus">meeus</a> for astronomy, and <a rel="nofollow" class="external text" href="http://paulsmith.github.io/gogeos/">gogeos</a> for <a href="/wiki/Geographic_information_systems" title="Geographic information systems" class="mw-redirect">GIS</a></li>
</ul>
</li>
</ul>
<p>Some sites help index the libraries outside the Go distribution:</p>
<ul>
<li><a rel="nofollow" class="external text" href="http://godoc.org/">godoc.org</a></li>
<li><a rel="nofollow" class="external text" href="https://github.com/search?l=Go&o=desc&q=stars%3A%3E50&ref=searchresults&s=stars&type=Repositories">GitHub's most starred repositories in Go</a></li>
<li><a rel="nofollow" class="external text" href="https://code.google.com/p/go-wiki/wiki/Projects">The Go Wiki's project page</a></li>
</ul>
<h2><span class="mw-headline" id="Community_and_conferences">Community and conferences</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=18" title="Edit section: Community and conferences">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><a rel="nofollow" class="external text" href="http://gopheracademy.com/">Gopher Academy</a>, Gopher Academy is a group of developers working to educate and promote the golang community.</li>
<li><a rel="nofollow" class="external text" href="http://golangprojects.com/">Golangprojects.com</a>, lists programming jobs and projects where companies are looking for people that know Go</li>
<li><a rel="nofollow" class="external text" href="http://www.gophercon.com/">GopherCon</a> The first Go conference. Denver, Colorado, USA April 24-26 2014</li>
<li><a rel="nofollow" class="external text" href="http://www.dotgo.eu/">dotGo</a> European conference. Paris, France October 10 2014</li>
<li><a rel="nofollow" class="external text" href="http://www.gophercon.in/">GopherConIndia</a> The first Go conference in India. Bangalore Feb. 19-21 2015</li>
</ul>
<h2><span class="mw-headline" id="Reception">Reception</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=19" title="Edit section: Reception">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Go's initial release led to much discussion.</p>
<p>Michele Simionato wrote in an article for artima.com:<sup id="cite_ref-63" class="reference"><a href="#cite_note-63"><span>[</span>62<span>]</span></a></sup></p>
<blockquote class="templatequote">
<p>Here I just wanted to point out the design choices about interfaces and inheritance. Such ideas are not new and it is a shame that no popular language has followed such particular route in the design space. I hope Go will become popular; if not, I hope such ideas will finally enter in a popular language, we are already 10 or 20 years too late :-(</p>
</blockquote>
<p>Dave Astels at <a href="/wiki/Engine_Yard" title="Engine Yard">Engine Yard</a> wrote:<sup id="cite_ref-64" class="reference"><a href="#cite_note-64"><span>[</span>63<span>]</span></a></sup></p>
<blockquote class="templatequote">
<p>Go is extremely easy to dive into. There are a minimal number of fundamental language concepts and the <a href="/wiki/Syntax_(programming_languages)" title="Syntax (programming languages)">syntax</a> is clean and designed to be clear and unambiguous. Go is still experimental and still a little rough around the edges.</p>
</blockquote>
<p><i><a href="/wiki/Ars_Technica" title="Ars Technica">Ars Technica</a></i> interviewed Rob Pike, one of the authors of Go, and asked why a new language was needed. He replied that:<sup id="cite_ref-ars_65-0" class="reference"><a href="#cite_note-ars-65"><span>[</span>64<span>]</span></a></sup></p>
<blockquote class="templatequote">
<p>It wasn't enough to just add features to existing programming languages, because sometimes you can get more in the long run by taking things away. They wanted to start from scratch and rethink everything. ... [But they did not want] to deviate too much from what developers already knew because they wanted to avoid alienating Go's target audience.</p>
</blockquote>
<p>Go was named Programming Language of the Year by the <a href="/wiki/TIOBE_Programming_Community_Index" title="TIOBE Programming Community Index" class="mw-redirect">TIOBE Programming Community Index</a> in its first year, 2009, for having a larger 12-month increase in popularity (in only 2 months, after its introduction in November) than any other language that year, and reached 13th place by January 2010,<sup id="cite_ref-66" class="reference"><a href="#cite_note-66"><span>[</span>65<span>]</span></a></sup> surpassing established languages like <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>. As of August 2014<sup class="plainlinks noprint asof-tag update" style="display:none;"><a class="external text" href="//en.wikipedia.org/w/index.php?title=Go_(programming_language)&action=edit">[update]</a></sup>, its ranking had dropped to 38th in the index, placing it lower than <a href="/wiki/COBOL" title="COBOL">COBOL</a> and <a href="/wiki/Fortran" title="Fortran">Fortran</a>.<sup id="cite_ref-67" class="reference"><a href="#cite_note-67"><span>[</span>66<span>]</span></a></sup> Go is already in commercial use by several large organizations.<sup id="cite_ref-68" class="reference"><a href="#cite_note-68"><span>[</span>67<span>]</span></a></sup></p>
<p>Regarding Go, <a href="/wiki/Bruce_Eckel" title="Bruce Eckel">Bruce Eckel</a> has stated:<sup id="cite_ref-69" class="reference"><a href="#cite_note-69"><span>[</span>68<span>]</span></a></sup></p>
<blockquote class="templatequote">
<p>The complexity of <a href="/wiki/C%2B%2B" title="C++">C++</a> (even more complexity has been added in the new C++), and the resulting impact on productivity, is no longer justified. All the hoops that the C++ programmer had to jump through in order to use a C-compatible language make no sense anymore -- they're just a waste of time and effort. Now, Go makes much more sense for the class of problems that C++ was originally intended to solve.</p>
</blockquote>
<h2><span class="mw-headline" id="Mascot">Mascot</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=20" title="Edit section: Mascot">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>Go's mascot is a <a href="/wiki/Gopher_(animal)" title="Gopher (animal)" class="mw-redirect">gopher</a> designed by <a href="/wiki/Ren%C3%A9e_French" title="Renée French">Renée French</a>, who also designed <a href="/wiki/Glenda,_the_Plan_9_Bunny" title="Glenda, the Plan 9 Bunny">Glenda, the Plan 9 Bunny</a>. The logo and mascot are licensed under <a href="/wiki/Creative_Commons" title="Creative Commons">Creative Commons</a> Attribution 3.0 license.<sup id="cite_ref-70" class="reference"><a href="#cite_note-70"><span>[</span>69<span>]</span></a></sup></p>
<h2><span class="mw-headline" id="Naming_dispute">Naming dispute</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=21" title="Edit section: Naming dispute">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>On the day of the general release of the language, Francis McCabe, developer of the <a href="/wiki/Go!_(programming_language)" title="Go! (programming language)">Go! programming language</a> (note the <a href="/wiki/Exclamation_point" title="Exclamation point" class="mw-redirect">exclamation point</a>), requested a name change of Google's language to prevent confusion with his language.<sup id="cite_ref-infoweek_71-0" class="reference"><a href="#cite_note-infoweek-71"><span>[</span>70<span>]</span></a></sup> The issue was closed by a Google developer on 12 October 2010 with the custom status "Unfortunate" and with the following comment: "there are many computing products and services named Go. In the 11 months since our release, there has been minimal confusion of the two languages."<sup id="cite_ref-72" class="reference"><a href="#cite_note-72"><span>[</span>71<span>]</span></a></sup></p>
<h2><span class="mw-headline" id="See_also">See also</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=22" title="Edit section: See also">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><a href="/wiki/Comparison_of_programming_languages" title="Comparison of programming languages">Comparison of programming languages</a></li>
<li><a href="/wiki/Dart_(programming_language)" title="Dart (programming language)">Dart</a>, another Google programming language</li>
</ul>
<div class="noprint tright portal" style="border:solid #aaa 1px;margin:0.5em 0 0.5em 1em;">
<table style="background:#f9f9f9;font-size:85%;line-height:110%;max-width:175px;">
<tr valign="middle">
<td style="text-align:center;"><a href="/wiki/File:Free_and_open-source_software_logo_(2009).svg" class="image"><img alt="Portal icon" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/28px-Free_and_open-source_software_logo_%282009%29.svg.png" width="28" height="28" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/42px-Free_and_open-source_software_logo_%282009%29.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/31/Free_and_open-source_software_logo_%282009%29.svg/56px-Free_and_open-source_software_logo_%282009%29.svg.png 2x" data-file-width="512" data-file-height="512" /></a></td>
<td style="padding:0 0.2em;vertical-align:middle;font-style:italic;font-weight:bold;"><a href="/wiki/Portal:Free_software" title="Portal:Free software">Free software portal</a></td>
</tr>
</table>
</div>
<h2><span class="mw-headline" id="Notes">Notes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=23" title="Edit section: Notes">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<div class="reflist" style="list-style-type: lower-alpha;">
<ol class="references">
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text">Usually, exactly one of the result and error values has a value other than the type's zero value; sometimes both do, as when a read or write can only be partially completed, and sometimes neither, as when a read returns 0 bytes. See <a href="/wiki/Semipredicate_problem#Multivalued_return" title="Semipredicate problem">Semipredicate problem: Multivalued return</a>.</span></li>
</ol>
</div>
<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=24" title="Edit section: References">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<div class="hatnote">This article incorporates material from the <a rel="nofollow" class="external text" href="http://golang.org/doc/go_tutorial.html">official Go tutorial</a>, which is licensed under the Creative Commons Attribution 3.0 license.</div>
<div class="reflist columns references-column-width" style="-moz-column-width: 30em; -webkit-column-width: 30em; column-width: 30em; list-style-type: decimal;">
<ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="https://groups.google.com/forum/m/#!topic/Golang-nuts/MYS5MkDF5_A">"Go 1.3.3 is released"</a>. <i>golang-nuts group</i>. 1 October 2014<span class="reference-accessdate">. Retrieved 5 November 2014</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Go+1.3.3+is+released&rft.date=1+October+2014&rft.genre=article&rft_id=https%3A%2F%2Fgroups.google.com%2Fforum%2Fm%2F%23%21topic%2FGolang-nuts%2FMYS5MkDF5_A&rft.jtitle=golang-nuts+group&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-langfaq-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-langfaq_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-langfaq_2-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-langfaq_2-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/go_faq.html">"Language Design FAQ"</a>. <i>golang.org</i>. 16 January 2010<span class="reference-accessdate">. Retrieved 27 February 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Language+Design+FAQ&rft.date=16+January+2010&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Fgo_faq.html&rft.jtitle=golang.org&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://go-lang.cat-v.org/os-ports">"Go Porting Efforts"</a>. <i>Go Language Resources</i>. cat-v. 12 January 2010<span class="reference-accessdate">. Retrieved 18 January 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Go+Porting+Efforts&rft.date=12+January+2010&rft.genre=article&rft_id=http%3A%2F%2Fgo-lang.cat-v.org%2Fos-ports&rft.jtitle=Go+Language+Resources&rft.pub=cat-v&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/LICENSE">"Text file LICENSE"</a>. <i>The Go Programming Language</i>. Google<span class="reference-accessdate">. Retrieved 5 October 2012</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Text+file+LICENSE&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2FLICENSE&rft.jtitle=The+Go+Programming+Language&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://code.google.com/p/go/source/browse/PATENTS">"Additional IP Rights Grant"</a>. <i>The Go Programming Language</i>. Google<span class="reference-accessdate">. Retrieved 5 October 2012</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Additional+IP+Rights+Grant&rft.genre=article&rft_id=http%3A%2F%2Fcode.google.com%2Fp%2Fgo%2Fsource%2Fbrowse%2FPATENTS&rft.jtitle=The+Go+Programming+Language&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><span class="citation news">Kincaid, Jason (10 November 2009). <a rel="nofollow" class="external text" href="http://www.techcrunch.com/2009/11/10/google-go-language/">"Google’s Go: A New Programming Language That’s Python Meets C++"</a>. <i>TechCrunch</i><span class="reference-accessdate">. Retrieved 18 January 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Google%E2%80%99s+Go%3A+A+New+Programming+Language+That%E2%80%99s+Python+Meets+C%2B%2B&rft.aufirst=Jason&rft.au=Kincaid%2C+Jason&rft.aulast=Kincaid&rft.date=10+November+2009&rft.genre=article&rft_id=http%3A%2F%2Fwww.techcrunch.com%2F2009%2F11%2F10%2Fgoogle-go-language%2F&rft.jtitle=TechCrunch&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-faq-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-faq_7-0">^</a></b></span> <span class="reference-text"><span class="citation news"><a rel="nofollow" class="external text" href="http://golang.org/doc/faq#Is_Google_using_go_internally">"Go FAQ: Is Google using Go internally?"</a><span class="reference-accessdate">. Retrieved 9 March 2013</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Go+FAQ%3A+Is+Google+using+Go+internally%3F&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Ffaq%23Is_Google_using_go_internally&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/install.html#tmp_33">"Installing Go"</a>. <i>golang.org</i>. The Go Authors. 11 June 2010<span class="reference-accessdate">. Retrieved 11 June 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Installing+Go&rft.date=11+June+2010&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Finstall.html%23tmp_33&rft.jtitle=golang.org&rft.pub=The+Go+Authors&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/go_faq.html#Implementation">"FAQ: Implementation"</a>. <i>golang.org</i>. 16 January 2010<span class="reference-accessdate">. Retrieved 18 January 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=FAQ%3A+Implementation&rft.date=16+January+2010&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Fgo_faq.html%23Implementation&rft.jtitle=golang.org&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://gcc.gnu.org/install/configure.html">"Installing GCC: Configuration"</a><span class="reference-accessdate">. Retrieved 3 December 2011</span>. "Ada, Go and Objective-C++ are not default languages"</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Installing+GCC%3A+Configuration&rft.genre=book&rft_id=http%3A%2F%2Fgcc.gnu.org%2Finstall%2Fconfigure.html&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><span class="citation web">Andrew Binstock (18 May 2011). <a rel="nofollow" class="external text" href="http://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480">"Dr. Dobb's: Interview with Ken Thompson"</a><span class="reference-accessdate">. Retrieved 7 February 2014</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.au=Andrew+Binstock&rft.aulast=Andrew+Binstock&rft.btitle=Dr.+Dobb%27s%3A+Interview+with+Ken+Thompson&rft.date=18+May+2011&rft.genre=book&rft_id=http%3A%2F%2Fwww.drdobbs.com%2Fopen-source%2Finterview-with-ken-thompson%2F229502480&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/faq#history">"Frequently Asked Questions (FAQ) - The Go Programming Language"</a>. Golang.org<span class="reference-accessdate">. Retrieved 2014-03-27</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Frequently+Asked+Questions+%28FAQ%29+-+The+Go+Programming+Language&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Ffaq%23history&rft.pub=Golang.org&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-go_lang_video_2009-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-go_lang_video_2009_13-0">^</a></b></span> <span class="reference-text"><span class="citation web">Pike, Rob. <a rel="nofollow" class="external text" href="http://www.youtube.com/watch?v=rKnDgT73v8s&feature=related">"The Go Programming Language"</a>. YouTube<span class="reference-accessdate">. Retrieved 1 Jul 2011</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.aufirst=Rob&rft.aulast=Pike&rft.au=Pike%2C+Rob&rft.btitle=The+Go+Programming+Language&rft.genre=book&rft_id=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrKnDgT73v8s%26feature%3Drelated&rft.pub=YouTube&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-techtalk-compiling-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-techtalk-compiling_14-0">^</a></b></span> <span class="reference-text"><span class="citation audio-visual"><a href="/wiki/Rob_Pike" title="Rob Pike">Rob Pike</a> (10 November 2009). <a rel="nofollow" class="external text" href="http://www.youtube.com/watch?v=rKnDgT73v8s#t=8m53"><i>The Go Programming Language</i></a> (flv) (Tech talk). Google. Event occurs at 8:53.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=The+Go+Programming+Language&rft.date=10+November+2009&rft.genre=book&rft_id=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DrKnDgT73v8s%23t%3D8m53&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies">Download and install packages and dependencies - go - The Go Programming Language</a>; see <a rel="nofollow" class="external text" href="http://godoc.org">godoc.org</a> for addresses and documentation of some packages</span></li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://godoc.org">godoc.org</a> and, for the standard library, <a rel="nofollow" class="external text" href="http://golang.org/pkg">golang.org/pkg</a></span></li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text">Rob Pike, on <a rel="nofollow" class="external text" href="http://5by5.tv/changelog/100">The Changelog</a> podcast</span></li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text">Rob Pike, <a rel="nofollow" class="external text" href="http://commandcenter.blogspot.de/2012/06/less-is-exponentially-more.html">Less is exponentially more</a></span></li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec#Assignability">Assignability - the Go Language Specification</a></span></li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec#Constants">Constants - the Go Language Specification</a></span></li>
<li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/go_tutorial.html">"A Tutorial for the Go Programming Language"</a>. <i>The Go Programming Language</i>. Google<span class="reference-accessdate">. Retrieved 10 March 2013</span>. "In Go the rule about visibility of information is simple: if a name (of a top-level type, function, method, constant or variable, or of a structure field or method) is capitalized, users of the package may see it. Otherwise, the name and hence the thing being named is visible only inside the package in which it is declared."</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=A+Tutorial+for+the+Go+Programming+Language&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Fgo_tutorial.html&rft.jtitle=The+Go+Programming+Language&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies">Download and install packages and dependencies - go - The Go Programming Language</a></span></li>
<li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/doc/effective_go.html#sharing">Share by communicating - Effective Go</a></span></li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text">Andrew Gerrand, <a rel="nofollow" class="external text" href="http://blog.golang.org/share-memory-by-communicating">Share memory by communicating</a></span></li>
<li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text">Andrew Gerrand, <a rel="nofollow" class="external text" href="http://golang.org/doc/codewalk/sharemem/">Codewalk: Share memory by communicating</a></span></li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text">For more discussion, see Rob Pike, <a rel="nofollow" class="external text" href="http://vimeo.com/49718712">Concurrency is not Parallelism</a></span></li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec">The Go Programming Language Specification</a>. This deliberately glosses over some details in the spec: <code>close</code>, channel range expressions, the two-argument form of the receive operator, unidrectional channel types, and so on.</span></li>
<li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://talks.golang.org/2012/concurrency.slide">Concurrency patterns in Go</a></span></li>
<li id="cite_note-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-30">^</a></b></span> <span class="reference-text">John Graham-Cumming, <a rel="nofollow" class="external text" href="http://blog.cloudflare.com/recycling-memory-buffers-in-go">Recycling Memory Buffers in Go</a></span></li>
<li id="cite_note-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-31">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/doc/play/tree.go">tree.go</a></span></li>
<li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text">Ewen Cheslack-Postava, <a rel="nofollow" class="external text" href="http://ewencp.org/blog/golang-iterators/">Iterators in Go</a></span></li>
<li id="cite_note-33"><span class="mw-cite-backlink"><b><a href="#cite_ref-33">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/pkg/sync/">sync - The Go Programming Language</a></span></li>
<li id="cite_note-memmodel-34"><span class="mw-cite-backlink">^ <a href="#cite_ref-memmodel_34-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-memmodel_34-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/go_mem.html">"The Go Memory Model"</a>. Google<span class="reference-accessdate">. Retrieved 5 January 2011</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=The+Go+Memory+Model&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Fgo_mem.html&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-35">^</a></b></span> <span class="reference-text">Russ Cox, <a rel="nofollow" class="external text" href="http://research.swtch.com/gorace">Off to the Races</a></span></li>
<li id="cite_note-SPLASH2012-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-SPLASH2012_36-0">^</a></b></span> <span class="reference-text"><span class="citation web"><a href="/wiki/Rob_Pike" title="Rob Pike">Rob Pike</a> (October 25, 2012). <a rel="nofollow" class="external text" href="http://talks.golang.org/2012/splash.article">"Go at Google: Language Design in the Service of Software Engineering"</a>. Google, Inc.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.aulast=Rob+Pike&rft.au=Rob+Pike&rft.btitle=Go+at+Google%3A+Language+Design+in+the+Service+of+Software+Engineering&rft.date=October+25%2C+2012&rft.genre=book&rft_id=http%3A%2F%2Ftalks.golang.org%2F2012%2Fsplash.article&rft.pub=Google%2C+Inc.&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span> "There is one important caveat: Go is not purely memory safe in the presence of concurrency."</span></li>
<li id="cite_note-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-37">^</a></b></span> <span class="reference-text">Brian W. Kernighan, <a rel="nofollow" class="external text" href="http://www.vitanuova.com/inferno/papers/descent.html">A Descent Into Limbo</a></span></li>
<li id="cite_note-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-38">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/pkg/io/#Reader">Reader - io - The Go Programming Language</a></span></li>
<li id="cite_note-39"><span class="mw-cite-backlink"><b><a href="#cite_ref-39">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/sha/Sha-2-256.unverified.test-vectors">SHA-256 test vectors</a>, set 1, vector #8</span></li>
<li id="cite_note-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-40">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/src/pkg/net/ip.go">src/pkg/net/ip.go</a></span></li>
<li id="cite_note-41"><span class="mw-cite-backlink"><b><a href="#cite_ref-41">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec#Type_assertions">Type Assertions - The Go Language Specification</a></span></li>
<li id="cite_note-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-42">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec#Type_switches">Type switches - The Go Language Specification</a></span></li>
<li id="cite_note-43"><span class="mw-cite-backlink"><b><a href="#cite_ref-43">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/pkg/reflect/#ValueOf">reflect.ValueOf(i interface{})</a> converts an <code>interface{}</code> to a <code>reflect.Value</code> that can be further inspected</span></li>
<li id="cite_note-44"><span class="mw-cite-backlink"><b><a href="#cite_ref-44">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://research.swtch.com/interfaces">"Go Data Structures: Interfaces"</a><span class="reference-accessdate">. Retrieved 15 November 2012</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Go+Data+Structures%3A+Interfaces&rft.genre=book&rft_id=http%3A%2F%2Fresearch.swtch.com%2Finterfaces&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-45"><span class="mw-cite-backlink"><b><a href="#cite_ref-45">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/ref/spec#Interface_types">Interface types - The Go Programming Language Specification</a></span></li>
<li id="cite_note-46"><span class="mw-cite-backlink"><b><a href="#cite_ref-46">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/effective_go.html#interfaces_and_types">"Effective Go — Interfaces and methods & Embedding"</a>. Google<span class="reference-accessdate">. Retrieved 28 November 2011</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Effective+Go%26nbsp%3B%E2%80%94+Interfaces+and+methods+%26+Embedding&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Feffective_go.html%23interfaces_and_types&rft.pub=Google&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-47"><span class="mw-cite-backlink"><b><a href="#cite_ref-47">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://code.google.com/p/go-wiki/wiki/PanicAndRecover">Panic And Recover</a>, Go wiki</span></li>
<li id="cite_note-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-48">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/doc/devel/weekly.html#2010-03-30">Release notes, 30 March 2010</a></span></li>
<li id="cite_note-49"><span class="mw-cite-backlink"><b><a href="#cite_ref-49">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://groups.google.com/group/golang-nuts/browse_thread/thread/1ce5cd050bb973e4">"Proposal for an exception-like mechanism"</a>. <i>golang-nuts</i>. 25 March 2010<span class="reference-accessdate">. Retrieved 25 March 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Proposal+for+an+exception-like+mechanism&rft.date=25+March+2010&rft.genre=article&rft_id=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fgolang-nuts%2Fbrowse_thread%2Fthread%2F1ce5cd050bb973e4&rft.jtitle=golang-nuts&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-50"><span class="mw-cite-backlink"><b><a href="#cite_ref-50">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://golang.org/doc/effective_go.html#commentary">Commentary - Effective Go</a></span></li>
<li id="cite_note-51"><span class="mw-cite-backlink"><b><a href="#cite_ref-51">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/go_tutorial.html">"A Tutorial for the Go Programming Language"</a>. <i>golang.org</i>. 16 January 2010<span class="reference-accessdate">. Retrieved 18 January 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=A+Tutorial+for+the+Go+Programming+Language&rft.date=16+January+2010&rft.genre=article&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Fgo_tutorial.html&rft.jtitle=golang.org&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-52"><span class="mw-cite-backlink"><b><a href="#cite_ref-52">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external free" href="https://gobyexample.com/reading-files">https://gobyexample.com/reading-files</a>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.genre=book&rft_id=https%3A%2F%2Fgobyexample.com%2Freading-files&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span> <span style="font-size:100%" class="error citation-comment">Missing or empty <code style="color:inherit; border:inherit; padding:inherit;">|title=</code> (<a href="/wiki/Help:CS1_errors#citation_missing_title" title="Help:CS1 errors">help</a>)</span></span></li>
<li id="cite_note-53"><span class="mw-cite-backlink"><b><a href="#cite_ref-53">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external free" href="http://golang.org/pkg/os/">http://golang.org/pkg/os/</a>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fpkg%2Fos%2F&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span> <span style="font-size:100%" class="error citation-comment">Missing or empty <code style="color:inherit; border:inherit; padding:inherit;">|title=</code> (<a href="/wiki/Help:CS1_errors#citation_missing_title" title="Help:CS1 errors">help</a>)</span></span></li>
<li id="cite_note-54"><span class="mw-cite-backlink"><b><a href="#cite_ref-54">^</a></b></span> <span class="reference-text">Erik Unger, <a rel="nofollow" class="external text" href="https://gist.github.com/ungerik/3731476">The Case For Go</a></span></li>
<li id="cite_note-55"><span class="mw-cite-backlink"><b><a href="#cite_ref-55">^</a></b></span> <span class="reference-text">Andrew Gerrand, <a rel="nofollow" class="external text" href="http://blog.golang.org/4years">Four years of Go</a>, The Go Blog</span></li>
<li id="cite_note-56"><span class="mw-cite-backlink"><b><a href="#cite_ref-56">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://talks.golang.org/2013/oscon-dl.slide">dl.google.com: Powered by Go</a></span></li>
<li id="cite_note-57"><span class="mw-cite-backlink"><b><a href="#cite_ref-57">^</a></b></span> <span class="reference-text">Matt Welsh, <a rel="nofollow" class="external text" href="http://matt-welsh.blogspot.com/2013/08/rewriting-large-production-system-in-go.html">Rewriting a Large Production System in Go</a></span></li>
<li id="cite_note-58"><span class="mw-cite-backlink"><b><a href="#cite_ref-58">^</a></b></span> <span class="reference-text">David Symonds, <a rel="nofollow" class="external text" href="http://talks.golang.org/2013/highperf.slide">High Performance Apps on Google App Engine</a></span></li>
<li id="cite_note-59"><span class="mw-cite-backlink"><b><a href="#cite_ref-59">^</a></b></span> <span class="reference-text">Patrick Lee, <a rel="nofollow" class="external text" href="https://tech.dropbox.com/2014/07/open-sourcing-our-go-libraries/">Open Sourcing Our Go Libraries</a>, 7 July 2014.</span></li>
<li id="cite_note-60"><span class="mw-cite-backlink"><b><a href="#cite_ref-60">^</a></b></span> <span class="reference-text">John Graham-Cumming, <a rel="nofollow" class="external text" href="http://blog.cloudflare.com/go-at-cloudflare">Go at CloudFlare</a></span></li>
<li id="cite_note-61"><span class="mw-cite-backlink"><b><a href="#cite_ref-61">^</a></b></span> <span class="reference-text">John Graham-Cumming, <a rel="nofollow" class="external text" href="http://blog.cloudflare.com/what-weve-been-doing-with-go">What we've been doing with Go</a></span></li>
<li id="cite_note-62"><span class="mw-cite-backlink"><b><a href="#cite_ref-62">^</a></b></span> <span class="reference-text">Peter Bourgon, <a rel="nofollow" class="external text" href="http://backstage.soundcloud.com/2012/07/go-at-soundcloud/">Go at SoundCloud</a></span></li>
<li id="cite_note-63"><span class="mw-cite-backlink"><b><a href="#cite_ref-63">^</a></b></span> <span class="reference-text"><span class="citation news">Simionato, Michele (15 November 2009). <a rel="nofollow" class="external text" href="http://www.artima.com/weblogs/viewpost.jsp?thread=274019">"Interfaces vs Inheritance (or, watch out for Go!)"</a>. artima<span class="reference-accessdate">. Retrieved 15 November 2009</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.aufirst=Michele&rft.aulast=Simionato&rft.au=Simionato%2C+Michele&rft.btitle=Interfaces+vs+Inheritance+%28or%2C+watch+out+for+Go%21%29&rft.date=15+November+2009&rft.genre=book&rft_id=http%3A%2F%2Fwww.artima.com%2Fweblogs%2Fviewpost.jsp%3Fthread%3D274019&rft.pub=artima&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-64"><span class="mw-cite-backlink"><b><a href="#cite_ref-64">^</a></b></span> <span class="reference-text"><span class="citation news">Astels, Dave (9 November 2009). <a rel="nofollow" class="external text" href="http://www.engineyard.com/blog/2009/ready-set-go/">"Ready, Set, Go!"</a>. engineyard<span class="reference-accessdate">. Retrieved 9 November 2009</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.au=Astels%2C+Dave&rft.aufirst=Dave&rft.aulast=Astels&rft.btitle=Ready%2C+Set%2C+Go%21&rft.date=9+November+2009&rft.genre=book&rft_id=http%3A%2F%2Fwww.engineyard.com%2Fblog%2F2009%2Fready-set-go%2F&rft.pub=engineyard&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-ars-65"><span class="mw-cite-backlink"><b><a href="#cite_ref-ars_65-0">^</a></b></span> <span class="reference-text"><span class="citation news">Paul, Ryan (10 November 2009). <a rel="nofollow" class="external text" href="http://arstechnica.com/open-source/news/2009/11/go-new-open-source-programming-language-from-google.ars">"Go: new open source programming language from Google"</a>. Ars Technica<span class="reference-accessdate">. Retrieved 13 November 2009</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.aufirst=Ryan&rft.aulast=Paul&rft.au=Paul%2C+Ryan&rft.btitle=Go%3A+new+open+source+programming+language+from+Google&rft.date=10+November+2009&rft.genre=book&rft_id=http%3A%2F%2Farstechnica.com%2Fopen-source%2Fnews%2F2009%2F11%2Fgo-new-open-source-programming-language-from-google.ars&rft.pub=Ars+Technica&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-66"><span class="mw-cite-backlink"><b><a href="#cite_ref-66">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://jaxenter.com/google-s-go-wins-programming-language-of-the-year-award-10069.html">"Google's Go Wins Programming Language Of The Year Award"</a>. jaxenter<span class="reference-accessdate">. Retrieved 5 December 2012</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Google%27s+Go+Wins+Programming+Language+Of+The+Year+Award&rft.genre=book&rft_id=http%3A%2F%2Fjaxenter.com%2Fgoogle-s-go-wins-programming-language-of-the-year-award-10069.html&rft.pub=jaxenter&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span> <span style="font-size:100%" class="error citation-comment"><code style="color:inherit; border:inherit; padding:inherit;">|first1=</code> missing <code style="color:inherit; border:inherit; padding:inherit;">|last1=</code> in Authors list (<a href="/wiki/Help:CS1_errors#first_missing_last" title="Help:CS1 errors">help</a>)</span></span></li>
<li id="cite_note-67"><span class="mw-cite-backlink"><b><a href="#cite_ref-67">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">"TIOBE Programming Community Index for August 2014"</a>. TIOBE Software. August 2014<span class="reference-accessdate">. Retrieved 22 August 2014</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=TIOBE+Programming+Community+Index+for+August+2014&rft.date=August+2014&rft.genre=book&rft_id=http%3A%2F%2Fwww.tiobe.com%2Findex.php%2Fcontent%2Fpaperinfo%2Ftpci%2Findex.html&rft.pub=TIOBE+Software&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-68"><span class="mw-cite-backlink"><b><a href="#cite_ref-68">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://go-lang.cat-v.org/organizations-using-go">"Organizations Using Go"</a>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=Organizations+Using+Go&rft.genre=book&rft_id=http%3A%2F%2Fgo-lang.cat-v.org%2Forganizations-using-go&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-69"><span class="mw-cite-backlink"><b><a href="#cite_ref-69">^</a></b></span> <span class="reference-text"><span class="citation web">Bruce Eckel (27 August 2011). <a rel="nofollow" class="external text" href="http://www.artima.com/weblogs/viewpost.jsp?thread=333589">"Calling Go from Python via JSON-RPC"</a><span class="reference-accessdate">. Retrieved 29 August 2011</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.au=Bruce+Eckel&rft.aulast=Bruce+Eckel&rft.btitle=Calling+Go+from+Python+via+JSON-RPC&rft.date=27+August+2011&rft.genre=book&rft_id=http%3A%2F%2Fwww.artima.com%2Fweblogs%2Fviewpost.jsp%3Fthread%3D333589&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-70"><span class="mw-cite-backlink"><b><a href="#cite_ref-70">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://golang.org/doc/faq#Whats_the_origin_of_the_mascot">"FAQ — The Go Programming Language"</a>. Golang.org<span class="reference-accessdate">. Retrieved 2013-06-25</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.btitle=FAQ%26nbsp%3B%E2%80%94+The+Go+Programming+Language&rft.genre=book&rft_id=http%3A%2F%2Fgolang.org%2Fdoc%2Ffaq%23Whats_the_origin_of_the_mascot&rft.pub=Golang.org&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-infoweek-71"><span class="mw-cite-backlink"><b><a href="#cite_ref-infoweek_71-0">^</a></b></span> <span class="reference-text"><span class="citation news">Claburn, Thomas (11 November 2009). <a rel="nofollow" class="external text" href="http://www.informationweek.com/news/software/web_services/showArticle.jhtml?articleID=221601351">"Google 'Go' Name Brings Accusations Of Evil<span style="padding-right:0.2em;">'</span>"</a>. InformationWeek<span class="reference-accessdate">. Retrieved 18 January 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.au=Claburn%2C+Thomas&rft.aufirst=Thomas&rft.aulast=Claburn&rft.btitle=Google+%27Go%27+Name+Brings+Accusations+Of+Evil%27&rft.date=11+November+2009&rft.genre=book&rft_id=http%3A%2F%2Fwww.informationweek.com%2Fnews%2Fsoftware%2Fweb_services%2FshowArticle.jhtml%3FarticleID%3D221601351&rft.pub=InformationWeek&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;"> </span></span></span></li>
<li id="cite_note-72"><span class="mw-cite-backlink"><b><a href="#cite_ref-72">^</a></b></span> <span class="reference-text"><span class="citation web"><a rel="nofollow" class="external text" href="http://code.google.com/p/go/issues/detail?id=9">"Issue 9 - go — I have already used the name for *MY* programming language"</a>. <i>Google Code</i>. <a href="/wiki/Google_Inc." title="Google Inc." class="mw-redirect">Google Inc.</a> <span class="reference-accessdate">Retrieved 12 October 2010</span>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Issue+9+-+go%26nbsp%3B%E2%80%94+I+have+already+used+the+name+for+%2AMY%2A+programming+language&rft.genre=article&rft_id=http%3A%2F%2Fcode.google.com%2Fp%2Fgo%2Fissues%2Fdetail%3Fid%3D9&rft.jtitle=Google+Code&rft.pub=Google+Inc.&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span></span></li>
</ol>
</div>
<h2><span class="mw-headline" id="External_links">External links</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=Go_(programming_language)&action=edit&section=25" title="Edit section: External links">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<ul>
<li><span class="official website"><span class="url"><a rel="nofollow" class="external text" href="https://golang.org">Official website</a></span></span></li>
<li><a rel="nofollow" class="external text" href="http://tour.golang.org/">A Tour of Go</a> (official)</li>
<li><a rel="nofollow" class="external text" href="http://go-lang.cat-v.org/">Go Programming Language Resources</a> (unofficial)</li>
<li><span class="citation web">Pike, Rob (28 April 2010). <a rel="nofollow" class="external text" href="http://www.stanford.edu/class/ee380/Abstracts/100428.html">"Another Go at Language Design"</a>. <i>Stanford EE Computer Systems Colloquium</i>. <a href="/wiki/Stanford_University" title="Stanford University">Stanford University</a>.</span><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fen.wikipedia.org%3AGo+%28programming+language%29&rft.atitle=Another+Go+at+Language+Design&rft.aufirst=Rob&rft.aulast=Pike&rft.au=Pike%2C+Rob&rft.date=28+April+2010&rft.genre=article&rft_id=http%3A%2F%2Fwww.stanford.edu%2Fclass%2Fee380%2FAbstracts%2F100428.html&rft.jtitle=Stanford+EE+Computer+Systems+Colloquium&rft.pub=Stanford+University&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal" class="Z3988"><span style="display:none;"> </span></span> (<a rel="nofollow" class="external text" href="https://www.youtube.com/watch?v=7VcArS4Wpqk">video</a>) — A university lecture</li>
</ul>
<table cellspacing="0" class="navbox" style="border-spacing:0;">
<tr>
<td style="padding:2px;">
<table cellspacing="0" class="nowraplinks hlist collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit;">
<tr>
<th scope="col" class="navbox-title" colspan="2">
<div class="plainlinks hlist navbar mini">
<ul>
<li class="nv-view"><a href="/wiki/Template:Google_Inc." title="Template:Google Inc."><span title="View this template" style=";;background:none transparent;border:none;;">v</span></a></li>
<li class="nv-talk"><a href="/wiki/Template_talk:Google_Inc." title="Template talk:Google Inc."><span title="Discuss this template" style=";;background:none transparent;border:none;;">t</span></a></li>
<li class="nv-edit"><a class="external text" href="//en.wikipedia.org/w/index.php?title=Template:Google_Inc.&action=edit"><span title="Edit this template" style=";;background:none transparent;border:none;;">e</span></a></li>
</ul>
</div>
<div style="font-size:110%;"><a href="/wiki/Google" title="Google">Google</a></div>
</th>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Outline_of_Google" title="Outline of Google">Overview</a></th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/History_of_Google" title="History of Google">History</a></li>
<li><a href="/wiki/List_of_mergers_and_acquisitions_by_Google" title="List of mergers and acquisitions by Google">List of mergers and acquisitions</a></li>
<li><a href="/wiki/List_of_Google_products" title="List of Google products">Products</a></li>
<li><a href="/wiki/Criticism_of_Google" title="Criticism of Google">Criticism</a></li>
<li><a href="/wiki/Censorship_by_Google" title="Censorship by Google">Censorship</a></li>
<li><a href="/wiki/List_of_Google_domains" title="List of Google domains">Domains</a></li>
<li><a href="/wiki/List_of_Google_hoaxes_and_easter_eggs" title="List of Google hoaxes and easter eggs">Hoaxes</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Advertising</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/DoubleClick_for_Publishers_by_Google" title="DoubleClick for Publishers by Google">Ad Manager</a></li>
<li><a href="/wiki/AdMob" title="AdMob">AdMob</a></li>
<li><a href="/wiki/Adscape" title="Adscape">Adscape</a></li>
<li><a href="/wiki/AdSense" title="AdSense">AdSense</a></li>
<li><a href="/wiki/Google_Certification_Program" title="Google Certification Program">Advertising Professionals</a></li>
<li><a href="/wiki/AdWords" title="AdWords">AdWords</a></li>
<li><a href="/wiki/Google_Analytics" title="Google Analytics">Analytics</a></li>
<li><a href="/wiki/DoubleClick" title="DoubleClick">DoubleClick</a></li>
<li><a href="/wiki/Google_Offers" title="Google Offers">Offers</a></li>
<li><a href="/wiki/Google_Wallet" title="Google Wallet">Wallet</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Communication</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_Alerts" title="Google Alerts">Alerts</a></li>
<li><a href="/wiki/Google_Apps_Script" title="Google Apps Script">Apps Script</a></li>
<li><a href="/wiki/Google_Calendar" title="Google Calendar">Calendar</a></li>
<li><a href="/wiki/Google_Contacts" title="Google Contacts">Contacts</a></li>
<li><a href="/wiki/Google_Friend_Connect" title="Google Friend Connect">Friend Connect</a></li>
<li><a href="/wiki/Gmail" title="Gmail">Gmail</a>
<ul>
<li><a href="/wiki/History_of_Gmail" title="History of Gmail">history</a></li>
<li><a href="/wiki/Gmail_interface" title="Gmail interface">interface</a></li>
</ul>
</li>
<li><a href="/wiki/Google%2B" title="Google+">Google+</a></li>
<li><a href="/wiki/Google_Groups" title="Google Groups">Groups</a></li>
<li><a href="/wiki/Google_Hangouts" title="Google Hangouts">Hangouts</a></li>
<li><a href="/wiki/Google_Inbox" title="Google Inbox">Inbox</a></li>
<li><a href="/wiki/Google_Sync" title="Google Sync">Sync</a></li>
<li><a href="/wiki/Google_Talk" title="Google Talk">Talk</a></li>
<li><a href="/wiki/Google_Text-to-Speech" title="Google Text-to-Speech">Text-to-Speech</a></li>
<li><a href="/wiki/Google_Translate" title="Google Translate">Translate</a></li>
<li><a href="/wiki/Google_transliteration" title="Google transliteration">Transliteration</a></li>
<li><a href="/wiki/Google_Voice" title="Google Voice">Voice</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Software</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_Chrome" title="Google Chrome">Chrome</a>
<ul>
<li><a href="/wiki/Google_Chrome_for_Android" title="Google Chrome for Android">for Android</a></li>
<li><a href="/wiki/Google_Chrome_for_iOS" title="Google Chrome for iOS" class="mw-redirect">for iOS</a></li>
<li><a href="/wiki/Chrome_Web_Store" title="Chrome Web Store">Chrome Web Store</a></li>
<li><a href="/wiki/Google_Chrome_Apps" title="Google Chrome Apps">Apps</a></li>
<li><a href="/wiki/Google_Chrome_Extensions" title="Google Chrome Extensions">Extensions</a></li>
</ul>
</li>
<li><a href="/wiki/Chrome_OS" title="Chrome OS">Chrome OS</a>
<ul>
<li><a href="/wiki/Chromebook" title="Chromebook">Chromebook</a></li>
<li><a href="/wiki/Chromebox" title="Chromebox">Chromebox</a></li>
<li><a href="/wiki/Chrome_Zone" title="Chrome Zone">Chrome Zone</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Cloud_Print" title="Google Cloud Print">Cloud Print</a></li>
<li><a href="/wiki/Google_Earth" title="Google Earth">Earth</a>
<ul>
<li><a href="/wiki/Google_Sky" title="Google Sky">Sky</a></li>
<li><a href="/wiki/Google_Moon" title="Google Moon">Moon</a></li>
<li><a href="/wiki/Google_Mars" title="Google Mars">Mars</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Gadgets" title="Google Gadgets">Gadgets</a></li>
<li><a href="/wiki/Google_Goggles" title="Google Goggles">Goggles</a></li>
<li><a href="/wiki/Google_IME" title="Google IME">IME</a>
<ul>
<li><a href="/wiki/Google_Pinyin" title="Google Pinyin">Pinyin</a></li>
<li><a href="/wiki/Google_Japanese_Input" title="Google Japanese Input">Japanese</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Keep" title="Google Keep">Keep</a></li>
<li><a href="/wiki/Google_News_%26_Weather" title="Google News & Weather">News & Weather</a></li>
<li><a href="/wiki/Google_Now" title="Google Now">Now</a></li>
<li><a href="/wiki/Picasa" title="Picasa">Picasa</a></li>
<li><a href="/wiki/Google_Play_Games" title="Google Play Games" class="mw-redirect">Play Games</a></li>
<li><a href="/wiki/Google_Play_Newsstand" title="Google Play Newsstand" class="mw-redirect">Play Newsstand</a></li>
<li><a href="/wiki/OpenRefine" title="OpenRefine">OpenRefine</a></li>
<li><a href="/wiki/Google_Toolbar" title="Google Toolbar">Toolbar</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Google_platform" title="Google platform">Platforms</a></th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_Account" title="Google Account">Account</a></li>
<li><a href="/wiki/Android_(operating_system)" title="Android (operating system)">Android</a>
<ul>
<li><a href="/wiki/Android_version_history" title="Android version history">Version history</a></li>
<li><a href="/wiki/Android_software_development" title="Android software development">Software development</a></li>
</ul>
</li>
<li><a href="/wiki/Google_App_Engine" title="Google App Engine">App Engine</a></li>
<li><a href="/wiki/Google_Apps" title="Google Apps" class="mw-redirect">Apps</a>
<ul>
<li><a href="/wiki/Google_Classroom" title="Google Classroom">Classroom</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Authenticator" title="Google Authenticator">Authenticator</a></li>
<li><a href="/wiki/BigTable" title="BigTable">BigTable</a></li>
<li><a href="/wiki/Zygote_Body" title="Zygote Body">Body</a></li>
<li><a href="/wiki/Google_Books" title="Google Books">Books</a></li>
<li><a href="/wiki/Caja_project" title="Caja project">Caja</a></li>
<li><a href="/wiki/Google_Cardboard" title="Google Cardboard">Cardboard</a></li>
<li><a href="/wiki/Chromecast" title="Chromecast">Chromecast</a></li>
<li><a href="/wiki/Google_Compute_Engine" title="Google Compute Engine">Compute Engine</a></li>
<li><a href="/wiki/Google_Contact_Lens" title="Google Contact Lens">Contact Lens</a></li>
<li><a href="/wiki/Google_Custom_Search" title="Google Custom Search">Custom Search</a></li>
<li><a href="/wiki/Dart_(programming_language)" title="Dart (programming language)">Dart</a></li>
<li><a href="/wiki/Google_Earth_Engine" title="Google Earth Engine">Earth Engine</a></li>
<li><a href="/wiki/Google_Fit" title="Google Fit">Fit</a></li>
<li><a href="/wiki/Google_Glass" title="Google Glass">Glass</a></li>
<li><strong class="selflink">Go</strong></li>
<li><a href="/wiki/Google_File_System" title="Google File System">GFS</a></li>
<li><a href="/wiki/Google_Apps_Marketplace" title="Google Apps Marketplace">Marketplace</a></li>
<li><a href="/wiki/Google_Native_Client" title="Google Native Client">Native Client</a></li>
<li><a href="/wiki/Google_Nexus" title="Google Nexus">Nexus</a></li>
<li><a href="/wiki/OpenSocial" title="OpenSocial">OpenSocial</a></li>
<li><a href="/wiki/Google_Play" title="Google Play">Play</a></li>
<li><a href="/wiki/Google_Public_DNS" title="Google Public DNS">Public DNS</a></li>
<li><a href="/wiki/Google_Questions_and_Answers" title="Google Questions and Answers">Q & A</a></li>
<li><a href="/wiki/Google_TV" title="Google TV">Google TV</a></li>
<li><a href="/wiki/Google_Wallet" title="Google Wallet">Wallet</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Development tools</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_APIs" title="Google APIs">AJAX APIs</a></li>
<li><a href="/wiki/App_Inventor_for_Android" title="App Inventor for Android">App Inventor</a></li>
<li><a href="/wiki/AtGoogleTalks" title="AtGoogleTalks">AtGoogleTalks</a></li>
<li><a href="/wiki/Google_Closure_Tools" title="Google Closure Tools">Closure Tools</a></li>
<li><a href="/wiki/Google_Developers" title="Google Developers">Developers</a></li>
<li><a href="/wiki/Google_Gadgets_API" title="Google Gadgets API">Gadgets API</a></li>
<li><a href="/wiki/GData" title="GData">GData</a></li>
<li><a href="/wiki/Googlebot" title="Googlebot">Googlebot</a></li>
<li><a href="/wiki/Google_Guava" title="Google Guava">Guava</a></li>
<li><a href="/wiki/Google_Guice" title="Google Guice">Guice</a></li>
<li><a href="/wiki/Google_platform#Software" title="Google platform">GWS</a></li>
<li><a href="/wiki/Keyhole_Markup_Language" title="Keyhole Markup Language">KML</a></li>
<li><a href="/wiki/MapReduce" title="MapReduce">MapReduce</a></li>
<li><a href="/wiki/Sitemaps" title="Sitemaps">Sitemaps</a></li>
<li><a href="/wiki/Google_Summer_of_Code" title="Google Summer of Code">Summer of Code</a></li>
<li><a href="/wiki/Google_Web_Toolkit" title="Google Web Toolkit">Web Toolkit</a></li>
<li><a href="/wiki/Google_Webmaster_Tools" title="Google Webmaster Tools">Webmaster Tools</a></li>
<li><a href="/wiki/Google_Website_Optimizer" title="Google Website Optimizer">Website Optimizer</a></li>
<li><a href="/wiki/Google_Swiffy" title="Google Swiffy">Swiffy</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Publishing</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Blogger_(service)" title="Blogger (service)">Blogger</a></li>
<li><a href="/wiki/Google_Bookmarks" title="Google Bookmarks">Bookmarks</a></li>
<li><a href="/wiki/Google_Docs" title="Google Docs">Docs</a></li>
<li><a href="/wiki/Google_Drive" title="Google Drive">Drive</a></li>
<li><a href="/wiki/FeedBurner" title="FeedBurner">FeedBurner</a></li>
<li><a href="/wiki/Google_Map_Maker" title="Google Map Maker">Map Maker</a></li>
<li><a href="/wiki/Panoramio" title="Panoramio">Panoramio</a></li>
<li><a href="/wiki/Picasa#Picasa_Web_Albums" title="Picasa">Picasa Web Albums</a></li>
<li><a href="/wiki/Google_Sites" title="Google Sites">Sites (JotSpot)</a></li>
<li><a href="/wiki/YouTube" title="YouTube">YouTube</a> (<a href="/wiki/Vevo" title="Vevo">Vevo</a>)</li>
<li><a href="/wiki/Zagat" title="Zagat">Zagat</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Google_Search" title="Google Search">Search</a> (<a href="/wiki/Timeline_of_Google_Search" title="Timeline of Google Search">timeline</a>)</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_Search_Appliance" title="Google Search Appliance">Appliance</a></li>
<li><a href="/wiki/Google_Audio_Indexing" title="Google Audio Indexing">Audio</a></li>
<li><a href="/wiki/Google_Blog_Search" title="Google Blog Search">Blog Search</a></li>
<li><a href="/wiki/Google_Books" title="Google Books">Books</a>
<ul>
<li><a href="/wiki/Google_Books_Library_Project" title="Google Books Library Project">Library Project</a></li>
<li><a href="/wiki/Google_eBooks" title="Google eBooks">eBooks</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Finance" title="Google Finance">Finance</a></li>
<li><a href="/wiki/Google_Images" title="Google Images">Images</a></li>
<li><a href="/wiki/Google_Maps" title="Google Maps">Maps</a>
<ul>
<li><a href="/wiki/Google_Street_View" title="Google Street View">Street View</a>
<ul>
<li><a href="/wiki/Timeline_of_Google_Street_View" title="Timeline of Google Street View">Timeline</a></li>
<li><a href="/wiki/Google_Street_View_privacy_concerns" title="Google Street View privacy concerns">Privacy concerns</a></li>
<li><a href="/wiki/Competition_of_Google_Street_View" title="Competition of Google Street View" class="mw-redirect">Competition</a></li>
<li><a href="/wiki/Locations_of_Google_Street_View" title="Locations of Google Street View" class="mw-redirect">Locations</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="/wiki/Google_News" title="Google News">News</a>
<ul>
<li><a href="/wiki/Google_News_Archive" title="Google News Archive">Archive</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Patents" title="Google Patents">Patents</a></li>
<li><a href="/wiki/Google_Scholar" title="Google Scholar">Scholar</a></li>
<li><a href="/wiki/Google_Shopping" title="Google Shopping">Shopping</a></li>
<li><a href="/wiki/Google_Groups" title="Google Groups">Usenet</a></li>
<li><a href="/wiki/Google_Voice_Search" title="Google Voice Search">Voice Search</a></li>
<li><a href="/wiki/Google_Search" title="Google Search">Web Search</a>
<ul>
<li><a href="/wiki/Google_Web_History" title="Google Web History">History</a></li>
<li><a href="/wiki/Google_Personalized_Search" title="Google Personalized Search">Personalized</a></li>
<li><a href="/wiki/Google_Real-Time_Search" title="Google Real-Time Search">Real-Time</a></li>
<li><a href="/wiki/Google_Search#Instant_Search" title="Google Search">Instant Search</a></li>
<li><a href="/wiki/SafeSearch" title="SafeSearch">SafeSearch</a></li>
</ul>
</li>
</ul>
</div>
<table cellspacing="0" class="nowraplinks navbox-subgroup" style="border-spacing:0;">
<tr>
<th scope="row" class="navbox-group">Algorithms</th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/PageRank" title="PageRank">PageRank</a></li>
<li><a href="/wiki/Google_Panda" title="Google Panda">Panda</a></li>
<li><a href="/wiki/Google_Penguin" title="Google Penguin">Penguin</a></li>
<li><a href="/wiki/Google_Hummingbird" title="Google Hummingbird">Hummingbird</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group">Analysis</th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Google_Insights_for_Search" title="Google Insights for Search">Insights for Search</a></li>
<li><a href="/wiki/Google_Trends" title="Google Trends">Trends</a></li>
<li><a href="/wiki/Knowledge_Graph" title="Knowledge Graph">Knowledge Graph</a></li>
</ul>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/List_of_Google_products#Discontinued_products_and_services" title="List of Google products">Discontinued</a></th>
<td class="navbox-list navbox-odd" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/Aardvark_(search_engine)" title="Aardvark (search engine)">Aardvark</a></li>
<li><a href="/wiki/Google_Answers" title="Google Answers">Answers</a></li>
<li><a href="/wiki/Google_Browser_Sync" title="Google Browser Sync">Browser Sync</a></li>
<li><a href="/wiki/Google_Base" title="Google Base">Base</a></li>
<li><a href="/wiki/Google_Buzz" title="Google Buzz">Buzz</a></li>
<li><a href="/wiki/Google_Checkout" title="Google Checkout">Checkout</a></li>
<li><a href="/wiki/Google_Chrome_Frame" title="Google Chrome Frame">Chrome Frame</a></li>
<li><a href="/wiki/AdWords#Google_Click-to-Call" title="AdWords">Click-to-Call</a></li>
<li><a href="/wiki/Google_Cloud_Connect" title="Google Cloud Connect">Cloud Connect</a></li>
<li><a href="/wiki/Google_Code_Search" title="Google Code Search">Code Search</a></li>
<li><a href="/wiki/Google_Currents" title="Google Currents">Currents</a></li>
<li><a href="/wiki/Google_Desktop" title="Google Desktop">Desktop</a></li>
<li><a href="/wiki/Google_Dictionary" title="Google Dictionary">Dictionary</a></li>
<li><a href="/wiki/Dodgeball_(service)" title="Dodgeball (service)">Dodgeball</a></li>
<li><a href="/wiki/Google_Fast_Flip" title="Google Fast Flip">Fast Flip</a></li>
<li><a href="/wiki/Gears_(software)" title="Gears (software)">Gears</a></li>
<li><a href="/wiki/GOOG-411" title="GOOG-411">GOOG-411</a></li>
<li><a href="/wiki/Jaiku" title="Jaiku">Jaiku</a></li>
<li><a href="/wiki/Knol" title="Knol">Knol</a></li>
<li><a href="/wiki/Google_Health" title="Google Health">Health</a></li>
<li><a href="/wiki/IGoogle" title="IGoogle">iGoogle</a></li>
<li><a href="/wiki/Google_Image_Labeler" title="Google Image Labeler">Image Labeler</a></li>
<li><a href="/wiki/Google_Labs" title="Google Labs">Labs</a></li>
<li><a href="/wiki/Google_Latitude" title="Google Latitude">Latitude</a></li>
<li><a href="/wiki/Google_Lively" title="Google Lively">Lively</a></li>
<li><a href="/wiki/Google_Mashup_Editor" title="Google Mashup Editor">Mashup Editor</a></li>
<li><a href="/wiki/Google_Notebook" title="Google Notebook">Notebook</a></li>
<li><a href="/wiki/Google_Pack" title="Google Pack">Pack</a></li>
<li><a href="/wiki/Google_Page_Creator" title="Google Page Creator">Page Creator</a></li>
<li><a href="/wiki/Picnik" title="Picnik">Picnik</a></li>
<li><a href="/wiki/Google_PowerMeter" title="Google PowerMeter">PowerMeter</a></li>
<li><a href="/wiki/Google_Reader" title="Google Reader">Reader</a></li>
<li><a href="/wiki/Google_Script_Converter" title="Google Script Converter">Script Converter</a></li>
<li><a href="/wiki/Google_SearchWiki" title="Google SearchWiki">SearchWiki</a></li>
<li><a href="/wiki/Google_Sidewiki" title="Google Sidewiki">Sidewiki</a></li>
<li><a href="/wiki/Slide.com" title="Slide.com">Slide</a></li>
<li><a href="/wiki/Google_Squared" title="Google Squared">Squared</a></li>
<li><a href="/wiki/Google_Pack#Google_Updater" title="Google Pack">Updater</a></li>
<li><a href="/wiki/Urchin_(software)" title="Urchin (software)">Urchin</a></li>
<li><a href="/wiki/Google_Videos" title="Google Videos">Videos</a></li>
<li><a href="/wiki/Google_Video_Marketplace" title="Google Video Marketplace">Video Marketplace</a></li>
<li><a href="/wiki/Apache_Wave" title="Apache Wave">Wave</a></li>
<li><a href="/wiki/Google_Web_Accelerator" title="Google Web Accelerator">Web Accelerator</a></li>
<li><a href="/wiki/Orkut" title="Orkut">Orkut</a></li>
</ul>
</div>
</td>
</tr>
<tr style="height:2px;">
<td colspan="2"></td>
</tr>
<tr>
<th scope="row" class="navbox-group"><a href="/wiki/Category:Google" title="Category:Google">Related</a></th>
<td class="navbox-list navbox-even" style="text-align:left;border-left-width:2px;border-left-style:solid;width:100%;padding:0px;">
<div style="padding:0em 0.25em;">
<ul>
<li><a href="/wiki/111_Eighth_Avenue" title="111 Eighth Avenue">111 Eighth Avenue</a></li>
<li><a href="/wiki/AI_Challenge" title="AI Challenge">AI Challenge</a></li>
<li><a href="/wiki/Google_Art_Project" title="Google Art Project">Art Project</a></li>
<li><a href="/wiki/Google_bomb" title="Google bomb">Bomb</a></li>
<li><a href="/wiki/Calico_(company)" title="Calico (company)">Calico (company)</a></li>
<li><a href="/wiki/Google_Current" title="Google Current">Current</a></li>
<li><a href="/wiki/Google_Chrome_Experiments" title="Google Chrome Experiments">Chrome Experiments</a></li>
<li><a href="/wiki/Google_Code_Jam" title="Google Code Jam">Code Jam</a></li>
<li><a href="/wiki/Google_Developer_Day" title="Google Developer Day">Developer Day</a></li>
<li><a href="/wiki/Google_Business_Groups" title="Google Business Groups">Google Business Groups</a></li>
<li><a href="/wiki/Google_Data_Liberation_Front" title="Google Data Liberation Front">Data Liberation</a>
<ul>
<li><a href="/wiki/Google_Takeout" title="Google Takeout">Takeout</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Developer_Expert" title="Google Developer Expert">Google Developer Expert</a></li>
<li><a href="/wiki/Google_Enterprise" title="Google Enterprise">Google Enterprise</a></li>
<li><a href="/wiki/Google_driverless_car" title="Google driverless car">Driverless car</a></li>
<li><a href="/wiki/Google_Fiber" title="Google Fiber">Fiber</a></li>
<li><a href="/wiki/Google.org#Google_Foundation" title="Google.org">Foundation</a></li>
<li><a href="/wiki/Google_China" title="Google China">Google China</a></li>
<li><a href="/wiki/Google_Shopping_Express" title="Google Shopping Express">Google Shopping Express</a></li>
<li><a href="/wiki/Googlization" title="Googlization">Googlization</a></li>
<li><a href="/wiki/Google_Grants" title="Google Grants">Grants</a></li>
<li><a href="/wiki/Google.org" title="Google.org">Google.org</a></li>
<li><a href="/wiki/Googleplex" title="Googleplex">Googleplex</a></li>
<li><a href="/wiki/Goojje" title="Goojje">Goojje</a></li>
<li><a href="/wiki/Google_Search#.22I.27m_Feeling_Lucky.22" title="Google Search">I'm Feeling Lucky</a></li>
<li><a href="/wiki/Google_I/O" title="Google I/O">I/O</a></li>
<li><a href="/wiki/Google_logo" title="Google logo">Logo</a></li>
<li><a href="/wiki/Google_Doodle" title="Google Doodle">Google Doodles</a>
<ul>
<li><a href="/wiki/List_of_Google_Doodles_(1998%E2%80%932009)" title="List of Google Doodles (1998–2009)">1998–2009</a></li>
<li><a href="/wiki/List_of_Google_Doodles_in_2010" title="List of Google Doodles in 2010">2010</a></li>
<li><a href="/wiki/List_of_Google_Doodles_in_2011" title="List of Google Doodles in 2011">2011</a></li>
<li><a href="/wiki/List_of_Google_Doodles_in_2012" title="List of Google Doodles in 2012">2012</a></li>
<li><a href="/wiki/List_of_Google_Doodles_in_2013" title="List of Google Doodles in 2013">2013</a></li>
<li><a href="/wiki/List_of_Google_Doodles_in_2014" title="List of Google Doodles in 2014">2014</a></li>
</ul>
</li>
<li><a href="/wiki/Google_Lunar_X_Prize" title="Google Lunar X Prize">Lunar X Prize</a></li>
<li><a href="/wiki/Material_Design" title="Material Design" class="mw-redirect">Material Design</a></li>
<li><a href="/wiki/Monopoly_City_Streets" title="Monopoly City Streets"
gitextract_hf53ko4u/
├── .github/
│ └── workflows/
│ └── test.yaml
├── .gitignore
├── LICENSE
├── README.md
├── display.go
├── go.mod
├── go.sum
├── parse.go
├── parse_test.go
├── pup.go
├── pup.rb
├── selector.go
└── tests/
├── README.md
├── cmds.txt
├── expected_output.txt
├── index.html
├── run.py
└── test
SYMBOL INDEX (52 symbols across 6 files)
FILE: display.go
function init (line 15) | func init() {
type Displayer (line 19) | type Displayer interface
function ParseDisplayer (line 23) | func ParseDisplayer(cmd string) error {
function isVoidElement (line 41) | func isVoidElement(n *html.Node) bool {
type TreeDisplayer (line 60) | type TreeDisplayer struct
method Display (line 63) | func (t TreeDisplayer) Display(nodes []*html.Node) {
method printPre (line 71) | func (t TreeDisplayer) printPre(n *html.Node) {
method printNode (line 118) | func (t TreeDisplayer) printNode(n *html.Node, level int) {
method printChildren (line 194) | func (t TreeDisplayer) printChildren(n *html.Node, level int) {
method printIndent (line 209) | func (t TreeDisplayer) printIndent(level int) {
type TextDisplayer (line 216) | type TextDisplayer struct
method Display (line 218) | func (t TextDisplayer) Display(nodes []*html.Node) {
type AttrDisplayer (line 241) | type AttrDisplayer struct
method Display (line 245) | func (a AttrDisplayer) Display(nodes []*html.Node) {
type JSONDisplayer (line 261) | type JSONDisplayer struct
method Display (line 315) | func (j JSONDisplayer) Display(nodes []*html.Node) {
function jsonify (line 264) | func jsonify(node *html.Node) map[string]interface{} {
type NumDisplayer (line 330) | type NumDisplayer struct
method Display (line 332) | func (d NumDisplayer) Display(nodes []*html.Node) {
FILE: parse.go
function ParseHTML (line 27) | func ParseHTML(r io.Reader, cs string) (*html.Node, error) {
function PrintHelp (line 46) | func PrintHelp(w io.Writer, exitCode int) {
function ParseArgs (line 67) | func ParseArgs() ([]string, error) {
function ProcessFlags (line 76) | func ProcessFlags(cmds []string) (nonFlagCmds []string, err error) {
function ParseCommands (line 138) | func ParseCommands(cmdString string) ([]string, error) {
FILE: parse_test.go
type parseCmdTest (line 7) | type parseCmdTest struct
function sliceEq (line 64) | func sliceEq(s1, s2 []string) bool {
function TestParseCommands (line 76) | func TestParseCommands(t *testing.T) {
FILE: pup.go
function main (line 21) | func main() {
FILE: pup.rb
class Pup (line 3) | class Pup < Formula
method install (line 15) | def install
FILE: selector.go
type Selector (line 14) | type Selector interface
type SelectorFunc (line 18) | type SelectorFunc
function Select (line 20) | func Select(s Selector) SelectorFunc {
function SelectNextSibling (line 44) | func SelectNextSibling(s Selector) SelectorFunc {
function SelectFromChildren (line 62) | func SelectFromChildren(s Selector) SelectorFunc {
type PseudoClass (line 76) | type PseudoClass
type CSSSelector (line 78) | type CSSSelector struct
method Match (line 84) | func (s CSSSelector) Match(node *html.Node) bool {
function ParseSelector (line 116) | func ParseSelector(cmd string) (selector CSSSelector, err error) {
function ParseTagMatcher (line 130) | func ParseTagMatcher(selector *CSSSelector, s scanner.Scanner) error {
function ParseClassMatcher (line 158) | func ParseClassMatcher(selector *CSSSelector, s scanner.Scanner) error {
function ParseIdMatcher (line 187) | func ParseIdMatcher(selector *CSSSelector, s scanner.Scanner) error {
function ParseAttrMatcher (line 216) | func ParseAttrMatcher(selector *CSSSelector, s scanner.Scanner) error {
function ParsePseudo (line 336) | func ParsePseudo(selector *CSSSelector, s scanner.Scanner) error {
function firstChildPseudo (line 396) | func firstChildPseudo(n *html.Node) bool {
function lastChildPseudo (line 406) | func lastChildPseudo(n *html.Node) bool {
function firstOfTypePseudo (line 416) | func firstOfTypePseudo(node *html.Node) bool {
function lastOfTypePseudo (line 429) | func lastOfTypePseudo(node *html.Node) bool {
function parseNthPseudo (line 441) | func parseNthPseudo(cmd string) (PseudoClass, error) {
function parseContainsPseudo (line 551) | func parseContainsPseudo(cmd string) (PseudoClass, error) {
function parseNotPseudo (line 598) | func parseNotPseudo(cmd string) (PseudoClass, error) {
function parseParentOfPseudo (line 618) | func parseParentOfPseudo(cmd string) (PseudoClass, error) {
Condensed preview — 18 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (251K chars).
[
{
"path": ".github/workflows/test.yaml",
"chars": 506,
"preview": "name: test\non: \n push:\n branches:\n - master\n pull_request:\n branches:\n - master\n\njobs:\n test:\n str"
},
{
"path": ".gitignore",
"chars": 53,
"preview": "dist/\ntestpages/*\ntests/test_results.txt\nrobots.html\n"
},
{
"path": "LICENSE",
"chars": 1056,
"preview": "Copyright (c) 2014: Eric Chiang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this so"
},
{
"path": "README.md",
"chars": 7517,
"preview": "# pup\n\npup is a command line tool for processing HTML. It reads from stdin,\nprints to stdout, and allows the user to fil"
},
{
"path": "display.go",
"chars": 7641,
"preview": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/fatih/color\"\n\tcolorable \"github.com/ma"
},
{
"path": "go.mod",
"chars": 371,
"preview": "module github.com/ericchiang/pup\n\ngo 1.13\n\nrequire (\n\tgithub.com/fatih/color v1.0.0\n\tgithub.com/mattn/go-colorable v0.0."
},
{
"path": "go.sum",
"chars": 1190,
"preview": "github.com/fatih/color v1.0.0 h1:4zdNjpoprR9fed2QRCPb2VTPU4UFXEtJc9Vc+sgXkaQ=\ngithub.com/fatih/color v1.0.0/go.mod h1:Zm"
},
{
"path": "parse.go",
"chars": 4424,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"golang.org/x/net/html\"\n\t\"golang.org/x/net/html/charse"
},
{
"path": "parse_test.go",
"chars": 3395,
"preview": "package main\n\nimport (\n\t\"testing\"\n)\n\ntype parseCmdTest struct {\n\tinput string\n\tsplit []string\n\tok bool\n}\n\nvar parseCm"
},
{
"path": "pup.go",
"chars": 1696,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"golang.org/x/net/html\"\n)\n\n// _=,_\n// o_/6 /#\\\n// \\__ |##/\n// ='|--\\\n/"
},
{
"path": "pup.rb",
"chars": 582,
"preview": "# This file was generated by release.sh\nrequire 'formula'\nclass Pup < Formula\n homepage 'https://github.com/ericchiang/"
},
{
"path": "selector.go",
"chars": 15242,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n\t\"text/scanner\"\n\n\t\"golang.org/x/net/html\"\n)\n\ntype"
},
{
"path": "tests/README.md",
"chars": 664,
"preview": "# Tests\n\nA simple set of tests to help maintain sanity.\n\nThese tests don't actually test functionality they only make su"
},
{
"path": "tests/cmds.txt",
"chars": 954,
"preview": "#footer\n#footer li\n#footer li + a\n#footer li + a attr{title}\n#footer li > li\ntable li\ntable li:first-child\ntable li:firs"
},
{
"path": "tests/expected_output.txt",
"chars": 2963,
"preview": "c00fef10d36c1166cb5ac886f9d25201b720e37e #footer\na7bb8dbfdd638bacad0aa9dc3674126d396b74e2 #footer li\nda39a3ee5e6b4b0d325"
},
{
"path": "tests/index.html",
"chars": 185180,
"preview": "<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\" class=\"client-nojs\">\n<head>\n<meta charset=\"UTF-8\" />\n<title>Go (programming la"
},
{
"path": "tests/run.py",
"chars": 396,
"preview": "#!/usr/bin/env python\n\nfrom __future__ import print_function\nfrom hashlib import sha1\nfrom subprocess import Popen, PIPE"
},
{
"path": "tests/test",
"chars": 88,
"preview": "#!/bin/bash\n\npython run.py > test_results.txt\ndiff expected_output.txt test_results.txt\n"
}
]
About this extraction
This page contains the full source code of the ericchiang/pup GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 18 files (228.4 KB), approximately 72.0k tokens, and a symbol index with 52 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.