code stringlengths 10 1.34M | language stringclasses 1
value |
|---|---|
// +build ignore,OMIT
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch *chan <- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
}
// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in *chan <- int, out *<-c... | Go |
// Package runner provides a Runner type that is used to define both RunCounter
// and EmbeddedRunCounter to show examples of how to use composition in Go.
package runner
import "fmt"
// A Task is a simple task that prints a message when run.
type Task struct{ Msg string }
func (t Task) Run() {
fmt.Println("running... | Go |
package runner
// RunCounter2 is completely equivalent to RunCounter,
// but uses struct embedding to avoid the boilerplate of redeclaring
// the Name method.
type RunCounter2 struct {
Runner // HL
count int
}
func NewRunCounter2(name string) *RunCounter2 {
return &RunCounter2{Runner{name}, 0}
}
func (r *RunCoun... | Go |
// +build OMIT
package main
import "fmt"
type Person struct{ Name string }
func (p Person) Introduce() { fmt.Println("Hi, I'm", p.Name) }
type Employee struct {
Person
EmployeeID int
}
func ExampleEmployee() {
var e Employee
e.Name = "Peter"
e.EmployeeID = 1234
e.Introduce()
}
| Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func sleepAndTalk(secs time.Duration, msg string, c chan string) {
time.Sleep(secs * time.Second)
c <- msg
}
func main() {
c := make(chan string)
go sleepAndTalk(0, "Hello", c)
go sleepAndTalk(1, "Gophers!", c)
go sleepAndTalk(2, "What's", c)
go sleepAnd... | Go |
// +build OMIT
package main
import (
"fmt"
"net/http"
)
var nextID = make(chan int)
func handler(w http.ResponseWriter, q *http.Request) {
fmt.Fprintf(w, "<h1>You got %v<h1>", <-nextID)
}
func main() {
http.HandleFunc("/next", handler)
go func() {
for i := 0; ; i++ {
nextID <- i
}
}()
http.ListenAndS... | Go |
// +build OMIT
package main
import (
"bytes"
"fmt"
"io"
"os"
)
var (
_ = bytes.Buffer{}
_ = os.Stdout
)
// WriteCounter tracks the total number of bytes written.
type WriteCounter struct {
io.ReadWriter
count int
}
func (w *WriteCounter) Write(b []byte) (int, error) {
w.count += len(b)
return w.ReadWrite... | Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func sleepAndTalk(t time.Duration, msg string) {
time.Sleep(t)
fmt.Printf("%v ", msg)
}
func main() {
go sleepAndTalk(0*time.Second, "Hello")
go sleepAndTalk(1*time.Second, "Gophers!")
go sleepAndTalk(2*time.Second, "What's")
go sleepAndTalk(3*time.Second,... | Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func f(left, right chan int) {
left <- 1 + <-right
}
func main() {
start := time.Now()
const n = 1000
leftmost := make(chan int)
right := leftmost
left := leftmost
for i := 0; i < n; i++ {
right = make(chan int)
go f(left, right)
left = right
}
... | Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func sleepAndTalk(t time.Duration, msg string) {
time.Sleep(t)
fmt.Printf("%v ", msg)
}
func main() {
sleepAndTalk(0*time.Second, "Hello")
sleepAndTalk(1*time.Second, "Gophers!")
sleepAndTalk(2*time.Second, "What's")
sleepAndTalk(3*time.Second, "up?")
}
| Go |
// +build OMIT
package main
import (
"bytes"
"net"
)
func handleConn(conn net.Conn) {
// does something that should be tested.
}
type loopBack struct {
net.Conn
buf bytes.Buffer
}
func (c *loopBack) Read(b []byte) (int, error) {
return c.buf.Read(b)
}
func (c *loopBack) Write(b []byte) (int, error) {
retur... | Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func sleepAndTalk(t time.Duration, msg string) {
time.Sleep(t)
fmt.Printf("%v ", msg)
}
func main() {
go sleepAndTalk(0*time.Second, "Hello")
go sleepAndTalk(1*time.Second, "Gophers!")
go sleepAndTalk(2*time.Second, "What's")
go sleepAndTalk(3*time.Second,... | Go |
// +build OMIT
package main
import (
"fmt"
"net/http"
)
var battle = make(chan string)
func handler(w http.ResponseWriter, q *http.Request) {
select {
case battle <- q.FormValue("usr"):
fmt.Fprintf(w, "You won!")
case won := <-battle:
fmt.Fprintf(w, "You lost, %v is better than you", won)
}
}
func main()... | Go |
// +build ignore
package main
import (
"fmt"
"unsafe"
)
// 1 START OMIT
var V1 = 0x01020304
var V2 [unsafe.Sizeof(V1)]byte
func main() {
*(*int)(unsafe.Pointer(&V2)) = V1
fmt.Println(V2)
}
// 1 END OMIT
| Go |
// +build ignore
package main
import "fmt"
// 1 START OMIT
const C1 = 1e+308
const C2 = C1 * 10
const C3 = C2 / 10
var V1 = C1
var V2 = V1 * 10
var V3 = V2 / 10
func main() {
fmt.Println(C3, V3)
}
// 1 END OMIT
| Go |
// +build ignore
package main
import (
"fmt"
"os"
)
// 1 START OMIT
var V = struct {
name string
os.FileMode
}{
name: "hello.go",
}
func main() {
fmt.Println(V)
}
// 1 END OMIT
| Go |
// +build ignore
package main
import "fmt"
// 2 START OMIT
// 1 START OMIT
func main() {
i := 1
f := func() T {
return T{
i: 1, // HL
}
}
fmt.Println(i, f())
}
// 1 END OMIT
type T map[int]int
// 2 END OMIT
| Go |
// +build ignore
package main
import "fmt"
// 1 START OMIT
const C1 = 1e-323
const C2 = C1 / 100
const C3 = C2 * 100
const C4 float64 = C1 / 100
const C5 = C4 * 100
func main() {
fmt.Println(C3, C5)
}
// 1 END OMIT
| Go |
// +build ignore
package main
import "fmt"
// 1 START OMIT
type F func(*State) F
type State int
func Begin(s *State) F {
*s = 1
return Middle
}
func Middle(s *State) F {
*s++
if *s >= 10 {
return End
}
return Middle
}
// 1 END OMIT
// 2 START OMIT
func End(s *State) F {
fmt.Println(*s)
return nil
}
fu... | Go |
// +build ignore
package main
import "fmt"
// 2 START OMIT
// 1 START OMIT
func main() {
i := 1
f := func() T {
return T{
i: 1, // HL
}
}
fmt.Println(i, f())
}
// 1 END OMIT
type T struct{ i int }
// 2 END OMIT
| Go |
// +build ignore
package main
import (
"fmt"
"runtime"
)
// 1 START OMIT
type P *P
type S []S
type C chan C
type M map[int]M
// 1 END OMIT
// 2 START OMIT
func Val(p *P) int {
if p == nil {
return 0
} else {
return 1 + Val(*p)
}
}
func Add(a, b *P) *P {
if b == nil {
return a
} else {
a1 := new(P)
... | Go |
// +build OMIT
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
)
func main() {
// START OMIT
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
}))
defer ts.Close()
res, err := http.Get(ts.URL)
if err !=... | Go |
package subprocess
import (
"fmt"
"os"
)
func Crasher() {
fmt.Println("Going down in flames!")
os.Exit(1)
}
| Go |
// +build OMIT
package main
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
)
func main() {
// START OMIT
handler := func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "something failed", http.StatusInternalServerError)
}
req, err := http.NewRequest("GET", "http://example.com/foo", nil)
if ... | Go |
// +build OMIT
package main
import (
"fmt"
"sort"
)
type Organ struct {
Name string
Weight Grams
}
func (o *Organ) String() string { return fmt.Sprintf("%v (%v)", o.Name, o.Weight) }
type Grams int
func (g Grams) String() string { return fmt.Sprintf("%dg", int(g)) }
type Organs []*Organ
func (s Organs) Le... | Go |
// +build OMIT
package main
import (
"fmt"
"sort"
)
type IntSlice []int
func (p IntSlice) Len() int { return len(p) }
func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func main() {
// START OMIT
s := []int{7, 5, 3, 11, 2}
... | Go |
// +build OMIT
package main
import (
"fmt"
"sort"
)
type Organ struct {
Name string
Weight Grams
}
func (o *Organ) String() string { return fmt.Sprintf("%v (%v)", o.Name, o.Weight) }
type Grams int
func (g Grams) String() string { return fmt.Sprintf("%dg", int(g)) }
// PART1 OMIT
type Organs []*Organ
fun... | Go |
// +build OMIT
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
func Walk(root *tree.Tree) *Walker {
return &Walker{stack: []*frame{{t: root}}}
}
type Walker struct {
stack []*frame
}
type frame struct {
t *tree.Tree
pc int
}
func (w *Walker) Next() (int, bool) {
if len(w.stack) == 0 {
re... | Go |
// +build OMIT
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
func Walk(root *tree.Tree) chan int {
ch := make(chan int)
go func() {
walk(root, ch)
close(ch)
}()
return ch
}
func walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
walk(t.Left, ch)
}
ch <- t.Value
if t.Right != nil ... | Go |
// +build OMIT
package main
import (
"fmt"
"io"
"log"
)
// ByteReader implements an io.Reader that emits a stream of its byte value.
type ByteReader byte
func (b ByteReader) Read(buf []byte) (int, error) {
for i := range buf {
buf[i] = byte(b)
}
return len(buf), nil
}
type LogReader struct {
io.Reader
}
... | Go |
// +build OMIT
package main
import (
"io"
"io/ioutil"
"log"
)
// ByteReader implements an io.Reader that emits a stream of its byte value.
type ByteReader byte
func (b ByteReader) Read(buf []byte) (int, error) {
for i := range buf {
buf[i] = byte(b)
}
return len(buf), nil
}
type LogReader struct {
io.Read... | Go |
// +build OMIT
package main
import "fmt"
type Organ struct {
Name string
Weight Grams
}
func (o *Organ) String() string { return fmt.Sprintf("%v (%v)", o.Name, o.Weight) }
type Grams int
func (g Grams) String() string { return fmt.Sprintf("%dg", int(g)) }
func main() {
s := []*Organ{{"brain", 1340}, {"heart... | Go |
// +build OMIT
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
func Walk(root *tree.Tree, quit chan struct{}) chan int {
ch := make(chan int)
go func() {
walk(root, ch, quit)
close(ch)
}()
return ch
}
func walk(t *tree.Tree, ch chan int, quit chan struct{}) {
if t.Left != nil {
walk(t.L... | Go |
// +build OMIT
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
func Walk(t *tree.Tree) {
if t.Left != nil {
Walk(t.Left)
}
fmt.Println(t.Value)
if t.Right != nil {
Walk(t.Right)
}
}
func main() {
Walk(tree.New(1))
}
| Go |
// +build OMIT
package main
type list struct {
buf [100000]byte
next *list
}
func main() {
var l *list
for {
l = &list{next: l}
}
}
| Go |
// +build OMIT
package main
import (
"log"
"os/exec"
)
func main() {
err := exec.Command("mkdir", "/tmp/foo").Run()
if err != nil {
log.Fatal(err)
}
err = exec.Command("rm", "-rf", "/tmp/foo").Run()
if err != nil {
log.Fatal(err)
}
}
| Go |
// +build OMIT
package main
func main() {
for {
}
}
| Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
fmt.Println(start)
for i := 0; i < 10; i++ {
time.Sleep(time.Nanosecond)
fmt.Println(time.Since(start))
}
}
| Go |
// +build OMIT
package main
func foo(a [1000]byte) {
foo(a)
}
func main() {
foo([1000]byte{})
}
| Go |
// +build OMIT
package main
import (
"log"
"os"
)
func main() {
err := os.RemoveAll("/foo")
if err != nil {
log.Fatal(err)
}
}
| Go |
// +build OMIT
package main
import "fmt"
func main() {
fmt.Println("Hello, gophers!")
}
| Go |
// +build OMIT
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
func main() {
res, err := http.Get("http://api.openweathermap.org/data/2.5/weather?q=Portland")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var w struct {
Weather []struct {
Desc string `json:"description"`
}... | Go |
// +build OMIT
package main
import (
"io"
"log"
"net"
"os"
)
func main() {
l, err := net.Listen("tcp", "127.0.0.1:4000")
if err != nil {
log.Fatal(err)
}
defer l.Close()
go dial()
c, err := l.Accept()
if err != nil {
log.Fatal(err)
}
defer c.Close()
io.Copy(os.Stdout, c)
}
func dial() {
c, err... | Go |
// +build OMIT
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Good night")
time.Sleep(8 * time.Hour)
fmt.Println("Good morning")
}
| Go |
// +build OMIT
package main
func main() {
c := make(chan int)
<-c
}
| Go |
// +build OMIT
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
const filename = "/tmp/file.txt"
err := ioutil.WriteFile(filename, []byte("Hello, file system\n"), 0644)
if err != nil {
log.Fatal(err)
}
b, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s"... | Go |
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
| Go |
package main
import (
"fmt"
"os"
)
const moved = `
The present tool has moved to the go.tools repository.
Please install it from its new location:
go get code.google.com/p/go.tools/cmd/present
`
func main() {
fmt.Print(moved)
os.Exit(1)
}
| Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package goplay
import (
"appengine"
"appengine/urlfetch"
"fmt"
"http"
"io"
"os"
)
const runUrl = "http://golang.org/compile?output=json"
func init() {... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pic
import (
"bytes"
"encoding/base64"
"fmt"
"image"
"image/png"
)
func Show(f func(int, int) [][]uint8) {
const (
dx = 256
dy = 256
)
da... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tree
import (
"fmt"
"math/rand"
)
// A Tree is a binary tree with integer values.
type Tree struct {
Left *Tree
Value int
Right *Tree
}
// New... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"encoding/json"
"log"
"net/http"
)
func init() {
http.HandleFunc("/compile", Compile)
}
type Response struct {
Output string `jso... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"flag"
"fmt"
"go/build"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package wc
import "fmt"
// Test runs a test suite against f.
func Test(f func(string) map[string]int) {
ok := true
for _, c := range testCases {
got := f... | Go |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"bufio"
"crypto/tls"
"io"
"net"
"net/http"
"net/url"
)
// DialError is an error that occurs while dialling a websocket server... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
// This file implements a protocol of hybi draft.
// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17
import (
"bufio"
"... | Go |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package websocket
import (
"bufio"
"fmt"
"io"
"net/http"
)
func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request, config *Co... | Go |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package websocket implements a client and server for the WebSocket protocol
// as specified in RFC 6455.
package websocket
import (
"bufio"
"crypto/tls"
... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
// All entities that do not end with ';' are 6 or fewer bytes long.
const longestEntityWithoutSemicolon = 6
// entity is a map from HTML entity n... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package atom provides integer codes (also known as atoms) for a fixed set of
// frequently occurring HTML strings: tag names and attribute keys such as "p"
/... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
// This program generates table.go and table_test.go.
// Invoke as
//
// go run gen.go |gofmt >table.go
// go run gen.go -test |... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"bytes"
"strings"
"unicode/utf8"
)
// These replacements permit compatibility with old numeric entities that
// assumed Windows-1252 ... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"bytes"
"io"
"strconv"
"strings"
"code.google.com/p/go.net/html/atom"
)
// A TokenType is the type of a Token.
type TokenType uint... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"bufio"
"errors"
"fmt"
"io"
"strings"
)
type writer interface {
io.Writer
WriteByte(c byte) error // in Go 1.1, use io.ByteWriter... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"errors"
"fmt"
"io"
"strings"
a "code.google.com/p/go.net/html/atom"
)
// A parser implements the HTML5 parsing algorithm:
// http... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
// Section 12.2.3.2 of the HTML5 specification says "The following elements
// have varying levels of special parsing rules".
// http://www.whatwg... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"strings"
)
func adjustAttributeNames(aa []Attribute, nameMap map[string]string) {
for i := range aa {
if newName, ok := nameMap[aa[... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"code.google.com/p/go.net/html/atom"
)
// A NodeType is the type of a Node.
type NodeType uint32
const (
ErrorNode NodeType = iota
T... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package html
import (
"strings"
)
// parseDoctype parses the data from a DoctypeToken into a name,
// public identifier, and system identifier. It returns a ... | Go |
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package html implements an HTML5-compliant tokenizer and parser.
Tokenization is done by creating a Tokenizer for an io.Reader r. It is the
caller's respons... | Go |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package spdy
// headerDictionary is the dictionary sent to the zlib compressor/decompressor.
var headerDictionary = []byte{
0x00, 0x00, 0x00, 0x07, 0x6f, 0x70... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package spdy
import (
"encoding/binary"
"io"
"net/http"
"strings"
)
func (frame *SynStreamFrame) write(f *Framer) error {
return f.writeSynStreamFrame(fr... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package spdy implements the SPDY protocol (currently SPDY/3), described in
// http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3.
package spdy
... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package spdy
import (
"compress/zlib"
"encoding/binary"
"io"
"net/http"
"strings"
)
func (frame *SynStreamFrame) read(h ControlFrameHeader, f *Framer) er... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package publicsuffix provides a public suffix list based on data from
// http://publicsuffix.org/. A public suffix is one under which Internet users
// can d... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
// This program generates table.go and table_test.go.
// Invoke as:
//
// go run gen.go -version "xxx" >table.go
// go run... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proxy
import (
"errors"
"io"
"net"
"strconv"
)
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address
// with an optional ... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proxy
import (
"net"
)
type direct struct{}
// Direct is a direct proxy: one that makes network connections directly.
var Direct = direct{}
func (d... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package proxy
import (
"net"
"strings"
)
// A PerHost directs connections to a default Dialer unless the hostname
// requested matches one of a number of ex... | Go |
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package proxy provides support for a variety of protocols to proxy network
// data.
package proxy
import (
"errors"
"net"
"net/url"
"os"
)
// A Dialer ... | Go |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package netutil provides network utility functions, complementing the more
// common ones in the net package.
package netutil
import (
"net"
"sync"
)
//... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"net"
"os"
"syscall"
"unsafe"
)
// Please refer to the online manual;
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd netbsd openbsd
package ipv4
import (
"net"
"os"
"syscall"
"unsafe"
)
func setControlMessage(fd int, opt *rawOpt, cf ControlFlag... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"net"
"reflect"
"syscall"
)
func (c *genericOpt) sysfd() (syscall.Handle, error) {
switch p := c.Conn.(type) {
case *net.TCPConn, ... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd windows
package ipv4
import (
"syscall"
)
// TOS returns the type-of-service field value for outgoing packets... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"net"
"syscall"
)
func (c *dgramOpt) MulticastTTL() (int, error) {
// TODO(mikio): Implement this
return 0, syscall.EPLAN9
}
func ... | Go |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// This program generates internet protocol constants by reading IANA
// protocol registries.
//
// Usage:
// go run gentest.go > iana_test.g... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"errors"
"net"
)
var (
errNoSuchInterface = errors.New("no such interface")
errNoSuchMulticastInterface = errors.New("no s... | Go |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
// An ICMPType represents a type of ICMP message.
type ICMPType int
func (typ ICMPType) String() string {
s, ok := icmpTypes[typ]
if !ok {
r... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"fmt"
"net"
"sync"
)
type rawOpt struct {
sync.Mutex
cflags ControlFlags
}
func (c *rawOpt) set(f ControlFlags) { c.cflags... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"os"
"syscall"
"unsafe"
)
// Linux provides a convenient path control option IP_PKTINFO that
// contains IP_SENDSRCADDR, IP_RECVDSTA... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd windows
package ipv4
import (
"bytes"
"net"
"syscall"
)
func setSyscallIPMreq(mreq *syscall.IPMreq, ifi *ne... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"net"
"os"
"syscall"
)
func ipv4ReceiveTOS(fd int) (bool, error) {
v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, syscall.IP_R... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"syscall"
)
func (c *genericOpt) TOS() (int, error) {
// TODO(mikio): Implement this
return 0, syscall.EPLAN9
}
func (c *genericOpt... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd
package ipv4
import (
"os"
"syscall"
)
func ipv4TOS(fd int) (int, error) {
v, err := syscall.GetsockoptInt(... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"net"
"syscall"
)
// A payloadHandler represents the IPv4 datagram payload handler.
type payloadHandler struct {
net.PacketConn
raw... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import (
"os"
"syscall"
)
func ipv4SendSourceAddress(fd int) (bool, error) {
v, err := syscall.GetsockoptInt(fd, ianaProtocolIP, syscall.IP_S... | Go |
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// This program generates internet protocol constatns and tables by
// reading IANA protocol registries.
//
// Usage of this program:
// go r... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import "syscall"
func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error {
// TODO(mikio): Implement this
retur... | Go |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4
import "syscall"
func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
// TODO(mikio): Implement this
return syscall.E... | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.