code
stringlengths
10
1.34M
language
stringclasses
1 value
// +build OMIT package main import ( "fmt" "math" ) func sqrt(x float64) string { if x < 0 { return sqrt(-x) + "i" } return fmt.Sprint(math.Sqrt(x)) } func main() { fmt.Println(sqrt(2), sqrt(-4)) }
Go
// +build OMIT package main func main() { for { } }
Go
// +build OMIT package main import "fmt" func main() { sum := 1 for sum < 1000 { sum += sum } fmt.Println(sum) }
Go
// +build OMIT package main import "fmt" func main() { sum := 0 for i := 0; i < 10; i++ { sum += i } fmt.Println(sum) }
Go
// +build OMIT package main import ( "fmt" "time" ) func main() { fmt.Println("When's Saturday?") today := time.Now().Weekday() switch time.Saturday { case today + 0: fmt.Println("Today.") case today + 1: fmt.Println("Tomorrow.") case today + 2: fmt.Println("In two days.") default: fmt.Println("Too ...
Go
// +build OMIT package main import ( "fmt" "runtime" ) func main() { fmt.Print("Go runs on ") switch os := runtime.GOOS; os { case "darwin": fmt.Println("OS X.") case "linux": fmt.Println("Linux.") default: // freebsd, openbsd, // plan9, windows... fmt.Printf("%s.", os) } }
Go
// +build OMIT package main import "fmt" func main() { sum := 1 for sum < 1000 { sum += sum } fmt.Println(sum) }
Go
// +build OMIT package main import ( "fmt" ) func Sqrt(x float64) float64 { } func main() { fmt.Println(Sqrt(2)) }
Go
package main import "fmt" func main() { defer fmt.Println("world") fmt.Println("hello") }
Go
// +build OMIT package main import ( "fmt" "time" ) func main() { t := time.Now() switch { case t.Hour() < 12: fmt.Println("Good morning!") case t.Hour() < 17: fmt.Println("Good afternoon.") default: fmt.Println("Good evening.") } }
Go
// +build OMIT package main import ( "fmt" "math" ) func pow(x, n, lim float64) float64 { if v := math.Pow(x, n); v < lim { return v } else { fmt.Printf("%g >= %g\n", v, lim) } // can't use v here, though return lim } func main() { fmt.Println( pow(3, 2, 10), pow(3, 3, 20), ) }
Go
package main import "fmt" func main() { fmt.Println("counting") for i := 0; i < 10; i++ { defer fmt.Println(i) } fmt.Println("done") }
Go
// +build OMIT package main import "fmt" func add(x, y int) int { return x + y } func main() { fmt.Println(add(42, 13)) }
Go
// +build OMIT package main import "fmt" func split(sum int) (x, y int) { x = sum * 4 / 9 y = sum - x return } func main() { fmt.Println(split(17)) }
Go
// +build OMIT package main import ( "fmt" "math" ) func main() { fmt.Println(math.pi) }
Go
// +build OMIT package main import "fmt" func swap(x, y string) (string, string) { return y, x } func main() { a, b := swap("hello", "world") fmt.Println(a, b) }
Go
package main import "fmt" func main() { var i int var f float64 var b bool var s string fmt.Printf("%v %v %v %q\n", i, f, b, s) }
Go
package main import "fmt" func main() { v := 42 // change me! fmt.Printf("v is of type %T\n", v) }
Go
// +build OMIT package main import "fmt" var i, j int = 1, 2 func main() { var c, python, java = true, false, "no!" fmt.Println(i, j, c, python, java) }
Go
// +build OMIT package main import "fmt" func main() { var i, j int = 1, 2 k := 3 c, python, java := true, false, "no!" fmt.Println(i, j, k, c, python, java) }
Go
// +build OMIT package main import ( "fmt" "math/cmplx" ) var ( ToBe bool = false MaxInt uint64 = 1<<64 - 1 z complex128 = cmplx.Sqrt(-5 + 12i) ) func main() { const f = "%T(%v)\n" fmt.Printf(f, ToBe, ToBe) fmt.Printf(f, MaxInt, MaxInt) fmt.Printf(f, z, z) }
Go
// +build OMIT package main import ( "fmt" "math" ) func main() { fmt.Printf("Now you have %g problems.", math.Nextafter(2, 3)) }
Go
// +build OMIT package main import ( "fmt" "math/rand" ) func main() { fmt.Println("My favorite number is", rand.Intn(10)) }
Go
// +build OMIT package main import "fmt" func add(x int, y int) int { return x + y } func main() { fmt.Println(add(42, 13)) }
Go
// +build OMIT package main import "fmt" const Pi = 3.14 func main() { const World = "世界" fmt.Println("Hello", World) fmt.Println("Happy", Pi, "Day") const Truth = true fmt.Println("Go rules?", Truth) }
Go
// +build OMIT package main import "fmt" var c, python, java bool func main() { var i int fmt.Println(i, c, python, java) }
Go
// +build OMIT package main import "fmt" const ( Big = 1 << 100 Small = Big >> 99 ) func needInt(x int) int { return x*10 + 1 } func needFloat(x float64) float64 { return x * 0.1 } func main() { fmt.Println(needInt(Small)) fmt.Println(needFloat(Small)) fmt.Println(needFloat(Big)) }
Go
// +build OMIT package main import ( "fmt" "math" ) func main() { var x, y int = 3, 4 var f float64 = math.Sqrt(float64(x*x + y*y)) var z int = int(f) fmt.Println(x, y, z) }
Go
// +build OMIT package main import ( "fmt" "math" ) func main() { hypot := func(x, y float64) float64 { return math.Sqrt(x*x + y*y) } fmt.Println(hypot(3, 4)) }
Go
// +build OMIT package main import ( "code.google.com/p/go-tour/wc" ) func WordCount(s string) map[string]int { return map[string]int{"x": 1} } func main() { wc.Test(WordCount) }
Go
// +build OMIT package main import "fmt" func main() { var a [2]string a[0] = "Hello" a[1] = "World" fmt.Println(a[0], a[1]) fmt.Println(a) }
Go
// +build OMIT package main import "fmt" type Vertex struct { X, Y int } var ( v1 = Vertex{1, 2} // has type Vertex v2 = Vertex{X: 1} // Y:0 is implicit v3 = Vertex{} // X:0 and Y:0 p = &Vertex{1, 2} // has type *Vertex ) func main() { fmt.Println(v1, p, v2, v3) }
Go
// +build OMIT package main import "fmt" type Vertex struct { X int Y int } func main() { fmt.Println(Vertex{1, 2}) }
Go
// +build OMIT package main import "fmt" type Vertex struct { Lat, Long float64 } var m = map[string]Vertex{ "Bell Labs": {40.68433, -74.39967}, "Google": {37.42202, -122.08408}, } func main() { fmt.Println(m) }
Go
// +build OMIT package main import "fmt" var pow = []int{1, 2, 4, 8, 16, 32, 64, 128} func main() { for i, v := range pow { fmt.Printf("2**%d = %d\n", i, v) } }
Go
// +build OMIT package main import "code.google.com/p/go-tour/pic" func Pic(dx, dy int) [][]uint8 { } func main() { pic.Show(Pic) }
Go
// +build OMIT package main import "fmt" func adder() func(int) int { sum := 0 return func(x int) int { sum += x return sum } } func main() { pos, neg := adder(), adder() for i := 0; i < 10; i++ { fmt.Println( pos(i), neg(-2*i), ) } }
Go
// +build OMIT package main import "fmt" type Vertex struct { X int Y int } func main() { v := Vertex{1, 2} v.X = 4 fmt.Println(v.X) }
Go
// +build OMIT package main import "fmt" func main() { a := make([]int, 5) printSlice("a", a) b := make([]int, 0, 5) printSlice("b", b) c := b[:2] printSlice("c", c) d := c[2:5] printSlice("d", d) } func printSlice(s string, x []int) { fmt.Printf("%s len=%d cap=%d %v\n", s, len(x), cap(x), x) }
Go
// +build OMIT package main import "fmt" type Vertex struct { Lat, Long float64 } var m map[string]Vertex func main() { m = make(map[string]Vertex) m["Bell Labs"] = Vertex{ 40.68433, -74.39967, } fmt.Println(m["Bell Labs"]) }
Go
// +build OMIT package main import "fmt" func main() { p := []int{2, 3, 5, 7, 11, 13} fmt.Println("p ==", p) for i := 0; i < len(p); i++ { fmt.Printf("p[%d] == %d\n", i, p[i]) } }
Go
package main import "fmt" func main() { var a []int printSlice("a", a) // append works on nil slices. a = append(a, 0) printSlice("a", a) // the slice grows as needed. a = append(a, 1) printSlice("a", a) // we can add more than one element at a time. a = append(a, 2, 3, 4) printSlice("a", a) } func pri...
Go
// +build OMIT package main import "fmt" func main() { i, j := 42, 2701 p := &i // point to i fmt.Println(*p) // read i through the pointer *p = 21 // set i through the pointer fmt.Println(i) // see the new value of i p = &j // point to j *p = *p / 37 // divide j through the point...
Go
// +build OMIT package main import "fmt" func main() { var z []int fmt.Println(z, len(z), cap(z)) if z == nil { fmt.Println("nil!") } }
Go
// +build OMIT package main import "fmt" type Vertex struct { X int Y int } func main() { v := Vertex{1, 2} p := &v p.X = 1e9 fmt.Println(v) }
Go
// +build OMIT package main import "fmt" func main() { m := make(map[string]int) m["Answer"] = 42 fmt.Println("The value:", m["Answer"]) m["Answer"] = 48 fmt.Println("The value:", m["Answer"]) delete(m, "Answer") fmt.Println("The value:", m["Answer"]) v, ok := m["Answer"] fmt.Println("The value:", v, "P...
Go
// +build OMIT package main import "fmt" // fibonacci is a function that returns // a function that returns an int. func fibonacci() func() int { } func main() { f := fibonacci() for i := 0; i < 10; i++ { fmt.Println(f()) } }
Go
// +build OMIT package main import "fmt" type Vertex struct { Lat, Long float64 } var m = map[string]Vertex{ "Bell Labs": Vertex{ 40.68433, -74.39967, }, "Google": Vertex{ 37.42202, -122.08408, }, } func main() { fmt.Println(m) }
Go
// +build OMIT package main import "fmt" func main() { pow := make([]int, 10) for i := range pow { pow[i] = 1 << uint(i) } for _, value := range pow { fmt.Printf("%d\n", value) } }
Go
// +build OMIT package main import "fmt" func main() { p := []int{2, 3, 5, 7, 11, 13} fmt.Println("p ==", p) fmt.Println("p[1:4] ==", p[1:4]) // missing low index implies 0 fmt.Println("p[:3] ==", p[:3]) // missing high index implies len(s) fmt.Println("p[4:] ==", p[4:]) }
Go
// +build OMIT package main import ( "fmt" "math" ) type Vertex struct { X, Y float64 } func (v *Vertex) Scale(f float64) { v.X = v.X * f v.Y = v.Y * f } func (v *Vertex) Abs() float64 { return math.Sqrt(v.X*v.X + v.Y*v.Y) } func main() { v := &Vertex{3, 4} v.Scale(5) fmt.Println(v, v.Abs()) }
Go
// +build OMIT package main import ( "io" "os" "strings" ) type rot13Reader struct { r io.Reader } func main() { s := strings.NewReader("Lbh penpxrq gur pbqr!") r := rot13Reader{s} io.Copy(os.Stdout, &r) }
Go
// +build OMIT package main import ( "fmt" "time" ) type MyError struct { When time.Time What string } func (e *MyError) Error() string { return fmt.Sprintf("at %v, %s", e.When, e.What) } func run() error { return &MyError{ time.Now(), "it didn't work", } } func main() { if err := run(); err != nil ...
Go
// +build OMIT package main import ( "fmt" ) func Sqrt(x float64) (float64, error) { return 0, nil } func main() { fmt.Println(Sqrt(2)) fmt.Println(Sqrt(-2)) }
Go
// +build OMIT package main import ( "fmt" "os" ) type Reader interface { Read(b []byte) (n int, err error) } type Writer interface { Write(b []byte) (n int, err error) } type ReadWriter interface { Reader Writer } func main() { var w Writer // os.Stdout implements Writer w = os.Stdout fmt.Fprintf(w, ...
Go
// +build OMIT package main import ( "fmt" "math" ) type MyFloat float64 func (f MyFloat) Abs() float64 { if f < 0 { return float64(-f) } return float64(f) } func main() { f := MyFloat(-math.Sqrt2) fmt.Println(f.Abs()) }
Go
package main import "code.google.com/p/go-tour/reader" type MyReader struct{} // TODO: Add a Read(byte) (int, error) method to MyReader. func main() { reader.Validate(MyReader{}) }
Go
package main import ( "fmt" "io" "strings" ) func main() { r := strings.NewReader("Hello, Reader!") b := make([]byte, 8) for { n, err := r.Read(b) fmt.Printf("n = %v err = %v b = %v\n", n, err, b) fmt.Printf("b[:n] = %q\n", b[:n]) if err == io.EOF { break } } }
Go
// +build OMIT package main import ( "log" "net/http" ) func main() { // your http.Handle calls here log.Fatal(http.ListenAndServe("localhost:4000", nil)) }
Go
// +build OMIT package main import ( "fmt" "image" ) func main() { m := image.NewRGBA(image.Rect(0, 0, 100, 100)) fmt.Println(m.Bounds()) fmt.Println(m.At(0, 0).RGBA()) }
Go
// +build OMIT package main import ( "fmt" "math" ) type Vertex struct { X, Y float64 } func (v *Vertex) Abs() float64 { return math.Sqrt(v.X*v.X + v.Y*v.Y) } func main() { v := &Vertex{3, 4} fmt.Println(v.Abs()) }
Go
package main import "fmt" type IPAddr [4]byte // TODO: Add a "String() string" method to IPAddr. func main() { addrs := map[string]IPAddr{ "loopback": {127, 0, 0, 1}, "googleDNS": {8, 8, 8, 8}, } for n, a := range addrs { fmt.Printf("%v: %v\n", n, a) } }
Go
// +build OMIT package main import ( "fmt" "math" ) type Abser interface { Abs() float64 } func main() { var a Abser f := MyFloat(-math.Sqrt2) v := Vertex{3, 4} a = f // a MyFloat implements Abser a = &v // a *Vertex implements Abser // In the following line, v is a Vertex (not *Vertex) // and does NOT...
Go
package main import "fmt" type Person struct { Name string Age int } func (p Person) String() string { return fmt.Sprintf("%v (%v years)", p.Name, p.Age) } func main() { a := Person{"Arthur Dent", 42} z := Person{"Zaphod Beeblebrox", 9001} fmt.Println(a, z) }
Go
// +build OMIT package main import ( "fmt" "log" "net/http" ) type Hello struct{} func (h Hello) ServeHTTP( w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello!") } func main() { var h Hello err := http.ListenAndServe("localhost:4000", h) if err != nil { log.Fatal(err) } }
Go
// +build OMIT package main import ( "code.google.com/p/go-tour/pic" "image" ) type Image struct{} func main() { m := Image{} pic.ShowImage(m) }
Go
package reader import ( "fmt" "io" "os" ) func Validate(r io.Reader) { b := make([]byte, 1024) i, o := 0, 0 for ; i < 1<<20 && o < 1<<20; i++ { // test 1mb n, err := r.Read(b) for i, v := range b[:n] { if v != 'A' { fmt.Fprintf(os.Stderr, "got byte %x at offset %v, want 'A'\n", v, o+i) return ...
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 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 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 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 main import ( "bytes" "encoding/json" "go/ast" "go/parser" "go/printer" "go/token" "net/http" ) func init() { http.HandleFunc("/fmt", fmtHand...
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 main import ( "bytes" "encoding/json" "fmt" "html/template" "io" "io/ioutil" "net/http" "os" "path/filepath" "strings" "time" "code.googl...
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. // +build !appengine package main import ( "flag" "fmt" "go/build" "io" "log" "net" "net/http" "net/url" "os" "os/exec" "path/filepath" "runtime"...
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. // +build appengine package main import ( "bufio" "bytes" "io" "net/http" "strings" "appengine" _ "code.google.com/p/go.tools/playground" ) const r...
Go
// The cascadia package is an implementation of CSS selectors. package cascadia import ( "errors" "fmt" "regexp" "strconv" "strings" "golang.org/x/net/html" ) // a parser for CSS selectors type parser struct { s string // the source text i int // the current position } // parseEscape parses a backslash e...
Go
package cascadia import ( "bytes" "fmt" "regexp" "strings" "golang.org/x/net/html" ) // the Selector type, and functions for creating them // A Selector is a function which tells whether a node matches or not. type Selector func(*html.Node) bool // hasChildMatch returns whether n has any child that matches a....
Go
// Copyright 2012, Google Inc. 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 ( "flag" "fmt" "math/rand" "os" "sync" "time" "code.google.com/p/vitess/go/vt/client2/tablet" ) func main() { goroutines := flag.Int...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgzip /* #cgo pkg-config: zlib #include "zlib.h" */ import "C" import ( "hash" "unsafe" ) type crc32Hash struct { crc C.uLong } // an empty buffer ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgzip // See http://www.zlib.net/zlib_how.html for more information on this /* #cgo pkg-config: zlib #include "zlib.h" // deflateInit2 is a macro, so u...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgzip /* #cgo pkg-config: zlib #include "zlib.h" */ import "C" import ( "hash" "unsafe" ) type adler32Hash struct { adler C.uLong } // an empty buf...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgzip /* #cgo pkg-config: zlib #include "zlib.h" // inflateInit2 is a macro, so using a wrapper function int cgzipInflateInit(z_stream *strm) { strm...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package bytes2 gives you alternate implementations of functionality // similar to go's bytes package package bytes2 import ( "code.google.com/p/vitess/go/hac...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package db defines an alternate (and simplified) // db api compared to go's database/sql. package db import ( "fmt" ) // Driver is the interface that must b...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proto import ( "bytes" "code.google.com/p/vitess/go/bson" "code.google.com/p/vitess/go/bytes2" "code.google.com/p/vitess/go/sqltypes" ) func Marshal...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proto import ( "code.google.com/p/vitess/go/sqltypes" ) type Field struct { Name string Type int64 } type QueryResult struct { Fields []Field ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mysql /* #cgo pkg-config: gomysql #include <stdlib.h> #include "vtmysql.h" */ import "C" import ( "fmt" "unsafe" "code.google.com/p/vitess/go/hack" ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package snitch import ( "code.google.com/p/vitess/go/relog" "fmt" "net/http" "runtime" ) const ( BaseUrl = "/debug/snitch" ) type SnitchCmd struct { url ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats import ( "encoding/json" "expvar" "sync" "time" ) type CountTracker interface { Counts() map[string]int64 } type Rates struct { mu ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats // Ring of int64 values // Not thread safe type RingInt64 struct { position int values []int64 } func NewRingInt64(capacity int) *RingInt64 { ...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats import ( "encoding/json" "expvar" "fmt" "sync" "time" ) type Timings struct { mu sync.Mutex TotalCount int64 TotalTime int64 Hist...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats import ( "bytes" "expvar" "fmt" "sync" "time" ) // The States structure keeps historical data about a state machine // state, and exports them...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats import ( "bytes" "expvar" "fmt" "sync" ) type Counters struct { mu sync.Mutex counts map[string]int64 } func NewCounters(name string) *C...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats import ( "bytes" "expvar" "fmt" "sync" ) type Histogram struct { cutoffs []int64 labels []string countLabel string totalLabel string...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package stats // StrFunc converts any function that returns a JSON string into // an expvar.Var compatible object. type StrFunc func() string func (f StrFunc) St...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bson import ( "io" "math" "reflect" "strconv" "time" "code.google.com/p/vitess/go/bytes2" ) var ( TimeType = reflect.TypeOf(time.Time{}) BytesT...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bson import ( "bytes" "encoding/binary" "errors" "fmt" "io" "math" "reflect" "strconv" "time" ) // BSON documents are lttle endian var Pack = b...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Utility functions for custom encoders package bson import ( "code.google.com/p/vitess/go/bytes2" ) func EncodeStringArray(buf *bytes2.ChunkedWriter, name st...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Utility functions for custom decoders package bson import ( "bytes" "math" "strconv" "time" "code.google.com/p/vitess/go/hack" ) var ( emptybytes = []...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package terminal import ( "syscall" "unsafe" ) // IsTerminal returns true if the given file descriptor is a terminal. func IsTerminal(fd uintptr) bool { var t...
Go
// Copyright 2012, Google Inc. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package timer provides timer functionality that can be controlled by the user. You start the timer by providing it a callback function, which it will call at...
Go