code
stringlengths
10
1.34M
language
stringclasses
1 value
package main import ( "fmt" "http" "io/ioutil" "os" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" body, err := iouti...
Go
package main import ( "http" "flag" "fmt" "io" "log" "net" "os" "strings" ) var ( post = flag.String("post", "", "urlencoded form data to POST") addr = flag.Bool("addr", false, "find open address and print to stdout") ) func main() { flag.Parse() if *addr { l, err := net.Listen("tcp", "127.0.0.1:0") ...
Go
package main import ( "fmt" "http" "io/ioutil" "os" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" body, err := iouti...
Go
package main import ( "fmt" "io/ioutil" "os" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) *Page { filename := title + ".txt" body, _ := ioutil.ReadFile(filename) ...
Go
package main import ( "http" "io/ioutil" "os" "template" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" body, err := ...
Go
package main import ( "os" "template" "io/ioutil" ) func main() { b, _ := ioutil.ReadAll(os.Stdin) template.HTMLFormatter(os.Stdout, "", b) }
Go
package main import ( "http" "io/ioutil" "os" "template" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" body, err := ...
Go
package main import ( "fmt" "io/ioutil" "os" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" body, err := ioutil.ReadFi...
Go
package main import ( "http" "io/ioutil" "os" "regexp" "template" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" bod...
Go
package main import ( "http" "io/ioutil" "os" "regexp" "template" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" bod...
Go
package main import ( "bytes" "flag" "go/parser" "go/printer" "go/ast" "go/token" "log" "os" "template" ) var ( srcFn = flag.String("src", "", "source filename") getName = flag.String("name", "", "func/type name to output") html = flag.Bool("html", true, "output HTML") showPkg = flag.Bool("pkg", fal...
Go
package main import ( "fmt" "http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) }
Go
package main import ( "http" "io/ioutil" "os" "regexp" "template" ) type Page struct { Title string Body []byte } func (p *Page) save() os.Error { filename := p.Title + ".txt" return ioutil.WriteFile(filename, p.Body, 0600) } func loadPage(title string) (*Page, os.Error) { filename := title + ".txt" bod...
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 ( "crypto/aes" "crypto/block" "compress/gzip" "io" "os" ) func EncryptAndGzip(dstfile, srcfile string, key, iv []byte) { r, _ := os...
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 ( "crypto/aes" "crypto/block" "compress/gzip" "io" "os" ) func EncryptAndGzip(dstfile, srcfile string, key, iv []byte) { r, _ := os...
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 ( "container/heap" "flag" "fmt" "rand" "time" ) const nRequester = 100 const nWorker = 10 var roundRobin = flag.Bool("r", false, "u...
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 ( "bufio" "fmt" "os" "strconv" "strings" ) // Generic expression parser/evaluator type Value interface { String() string BinaryOp...
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 ( "bufio" "fmt" "os" "strconv" "strings" ) // Generic expression parser/evaluator type Value interface { String() string BinaryOp...
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. // Process plain text into HTML. // - h2's are made from lines followed by a line "----\n" // - tab-indented blocks become <pre> blocks // - blank lines become ...
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 main import "fmt" // Send the sequence 2, 3, 4, ... to returned channel func generate() chan int { ch := make(chan int) go func(){ for i := 2; ; ...
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 main import ( "./file" "flag" "fmt" "os" ) func cat(f *file.File) { const NBUF = 512 var buf [NBUF]byte for { switch nr, er := f.Read(buf[:])...
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 main import "fmt" func main() { var u64 uint64 = 1<<64-1 fmt.Printf("%d %d\n", u64, int64(u64)) // harder stuff type T struct { a int b strin...
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 main import "fmt" type testType struct { a int b string } func (t *testType) String() string { return fmt.Sprint(t.a) + " " + t.b } func main() {...
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 main import "os" func main() { s := "hello" if s[1] != 'e' { os.Exit(1) } s = "good bye" var p *string = &s *p = "ciao" }
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 main import "fmt" // Send the sequence 2, 3, 4, ... to channel 'ch'. func generate(ch chan int) { for i := 2; ; i++ { ch <- i // Send 'i' to chann...
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 main import ( "./file" "fmt" "os" ) func main() { hello := []byte("hello, world\n") file.Stdout.Write(hello) f, err := file.Open("/does/not/exis...
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 file import ( "os" "syscall" ) type File struct { fd int // file descriptor number name string // file name at Open time } func newFile(fd i...
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 main import ( "os" "flag" // command line option parser ) var omitNewline = flag.Bool("n", false, "don't print final newline") const ( Space = " ...
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 main import "fmt" type request struct { a, b int replyc chan int } type binOp func(a, b int) int func run(op binOp, req *request) { reply := ...
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 main import ( "./file" "flag" "fmt" "os" ) var rot13Flag = flag.Bool("rot13", false, "rot13 the input") func rot13(b byte) byte { if 'a' <= b &&...
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 main import ( "fmt" "./sort" ) func ints() { data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586} a := sort.IntSlice(d...
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 main import "fmt" type request struct { a, b int replyc chan int } type binOp func(a, b int) int func run(op binOp, req *request) { reply := op(r...
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 main import "fmt" func sum(a []int) int { // returns an int s := 0 for i := 0; i < len(a); i++ { s += a[i] } return s } func main() { s := su...
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 main import fmt "fmt" // Package implementing formatted I/O. func main() { fmt.Printf("Hello, world; or Καλημέρα κόσμε; or こんにちは 世界\n") }
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 sort type Interface interface { Len() int Less(i, j int) bool Swap(i, j int) } func Sort(data Interface) { for i := 1; i < data.Len(); i++ { for...
Go
// $G $D/$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 P import ( ) const ( ) var ( ) type ( )
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 ( "fmt" "math" "strings" ) type Error interface { String() string } type ErrorTest struct { nam...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main import ( "fmt" "os" "utf8" ) func main() { s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx" ...
Go
// errchk $G $D/$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 main type T struct { } func (t *T) M(int, string) // GCCGO_ERROR "previous" func (t *T) M(int, float64) { } // ERROR "redeclar...
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. // Garbage collection benchmark: parse Go packages repeatedly. package main import ( "flag" "fmt" "go/ast" "go/parser" "go/token" "os" "path" "runtim...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main import ( "fmt" "runtime" "time" ) type Number struct { next *Number } // ----------------------------...
Go
/* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form ...
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 ( "fmt" "runtime" "sort" ) func gcstats(name string, n int, t int64) { st := &runtime.MemStats fmt.Printf("garbage.%sMem Alloc=%d/%d...
Go
// $G $D/$F.go && $L $F.$A && // ./$A.out -pass 0 >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1 && // ./$A.out -pass 1 >tmp.go && errchk $G -e tmp.go && // ./$A.out -pass 2 >tmp.go && errchk $G -e tmp.go // rm -f tmp.go $A.out1 // Copyright 2010 The Go Authors. All rights reserved. // Use of this source c...
Go
// errchk $G -e $D/$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 main import "io" func whatis(x interface{}) string { switch x.(type) { case int: return "int" case int: // ERROR "dupli...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail", msg, "\n") ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: compos // 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 main type T struct { int } func f() *T { return &T{1} } func main() { x := f() y := ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 ( "runtime" "strings" ) var didbug bool func bug() { if didbug { return } println("BUG") ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Check that static interface conversion of // interface value nil succeeds. package main type R interface { R() } ty...
Go
// $G $D/$F.go || echo BUG: should compile // 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. // Check mutually recursive interfaces package main type I1 interface { foo() I2 } type I2 interface { bar() I1...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG interface6 // 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. // Interface values containing structures. package main import "os" var fail int func check(b...
Go
// errchk $G -e $D/$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. // Check methods derived from embedded interface and *interface values. package main import "os" const Value = 1e12 type Inter int...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Interface comparisons using types hidden // inside reflected-on structs. package main import "reflect" type T stru...
Go
// $G $D/${F}1.go && errchk $G $D/$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 main import "./private1" type Exported interface { private() } type Implementation struct{} func (p *Imple...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Check uses of all the different interface // conversion runtime functions. package main type Stringer interface { ...
Go
// errchk $G $D/$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. // Check that interface{M()} = *interface{M()} produces a compiler error. package main type Inst interface { Next() *Inst } type Rege...
Go
// errchk $G -e $D/$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. // Static error messages about interface conversions. package main type T struct { a int } var t *T type I interface { M() } va...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Check methods derived from embedded interface values. package main import "os" const Value = 1e12 type Inter inte...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Check that static interface conversion of // interface value nil succeeds. package main type R interface { R() } ty...
Go
// errchk $G $D/$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. // Error messages about missing implicit methods. package main type T int func (t T) V() func (t *T) P() type V interface { V() } ty...
Go
// $G $D/$F.go && $L $F.$A && ! ./$A.out // 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. // Check that interface conversion fails when method is missing. package main type I interface { Foo() } func main...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Implicit methods for embedded types. // Mixed pointer and non-pointer receivers. package main type T int var nv, n...
Go
// $G $D/embed0.go && $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Check that embedded interface types can have local methods. package main import "./embed0" type...
Go
// $G $D/$F.go && $L $F.$A && (! ./$A.out || echo BUG: should not succeed) // 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. // Check methods with different return types. package main type S struct { a int }...
Go
// true # used by private.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 p type Exported interface { private() } type Implementation struct{} func (p *Implementation) private() {} var X = n...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // check that big vs small, pointer vs not // interface methods work. package main type I interface { M() int64 } typ...
Go
// true # used by embed1.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. // Check that embedded interface types can have local methods. package p type T int func (t T) m() {} type I interface { m() } t...
Go
// errchk $G -e $D/$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 main func main() { var n byte // ERROR "not a type|expected type" var y = float(0) // ERROR "cannot call|expected fu...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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. // trivial finalizer test package main import ( "runtime" "time" ) const N = 250 type A struct { b *B n int } t...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main import "runtime" func mk2() { b := new([10000]byte) _ = b // println(b, "stored at", &b) } func mk1() { ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main type T chan uint64 func M(f uint64) (in, out T) { in = make(T, 100) out = make(T, 100) go func(in, out T,...
Go
// errchk $G -e $D/$F.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 func use(bool) {} type T1 *int type T2 *int type T3 struct {} var t3 T3 func main() { // Arguments to comparison mu...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main import "os" var ecode int func assert(a, b, c string) { if a != b { ecode = 1 print("FAIL: ", c, ": ",...
Go
// $G $D/$F.go && $L $F.$A && ! ./$A.out // 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 main func use(bool) { } func main() { var a []int var ia interface{} = a use(ia == ia) }
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main // check for correct heap-moving of escaped variables. // it is hard to check for the allocations, but it ...
Go
// $G $F.go && $L $F.$A && ./$A.out // 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 main import "container/vector" type S struct { val int } func (p *S) Init(val int) *S { p.val = val return ...
Go
// errchk $G -e $D/$F.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 var ( f32 float32 f64 float64 c64 complex64 c128 complex128 ) func main() { // ok c64 = complex(f32, f32) c128...
Go
// errchk $G -e $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. // Incorrect short declarations and redeclarations. package main func f1() int { return 1 } func f2() (float32, int)...
Go
// $G $D/$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 main func f(interface{}) func g() {} func main() { f(map[string]string{"a":"b","c":"d"}) f([...]int{1,2,3}) f(map[string]func(){"a":...
Go
// $G $D/$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 main type T struct { s string; } func main() { s := ""; l1 := len(s); var t T; l2 := len(t.s); // BUG: cannot take len() of a st...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 var n int func f() int { n++ return n } func main() { x := []int{0,1,2,3,4,5,6,7,8,9,10} n = 5 y :...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main type T struct { i int } func main() { var ta []*T; ta = new([1]*T)[0:]; ta[0] = nil; } /* bug045.go:...
Go
// $G $D/$F.go && $L $F.$A || echo BUG: bug155 // 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 main const big uint64 = 1<<63 func f(a uint64) uint64 { return a << big } func main() { f(1) } /* ...
Go
// errchk $G -e $D/$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 main func main() { var i int = 100 i = i << -3 // ERROR "overflows|negative" } /* ixedbugs/bug016.go:7: overflow convertin...
Go
// errchk $G $D/$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 main import "fmt" // GCCGO_ERROR "previous" var fmt int // ERROR "redecl|redefinition"
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main func main() { type T struct { s string f float64 } var s string = "hello" var f float64 = 0.2 t ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug260 failed // Test that structures pack densely, according to the alignment of the largest field. package main import ( "fmt" "os" "strconv" ) type T1 struct { x uint8 } type T2 struct { x uint16 } type T4 struct { x uint32 } func main() { report := len...
Go
// $G $D/$F.go || echo BUG: fails incorrectly // 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 main const s string = "foo"; func main() { i := len(s); // should be legal to take len() of a constan...
Go
// errchk $G $D/$F.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. // Use //line to set the line number of the next line to 20. //line fixedbugs/bug305.go:20 package p // Introduce an error which shoul...
Go
// $G $D/$F.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. // Used to run out of registers on 8g. Issue 868. package main func main() { var r uint32 var buf [4]byte a := buf[0:4] r = (((((uint32(...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main type Type interface { TypeName() string; } type TInt struct { } // TInt func (i *TInt) TypeName() strin...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main func main() { var len int; // len should not be a keyword - this doesn't compile _ = len; }
Go
// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.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. ignored
Go
// $G $D/$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 main type I interface { X(...int) }
Go
// $G $D/$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 main const c = 0 ^ 0
Go
// errchk $G $D/$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 main type T struct { f int; } // 6g used to get confused by the f:1 above // and allow uses of f that would be silently // dro...
Go
// errchk $G $D/$F.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 p import ( "bytes" "fmt" ) type t int func main() { _ = t.bar // ERROR "no method" var b bytes.Buffer fmt.Print(b) // ER...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main type T1 struct { x, y int } type T2 struct { z, w byte } type T3 T1 type MyInt int func (MyInt) m(*T1)...
Go
// errchk $G $D/$F.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 type I1 interface { m() I2 I2 // GCCGO_ERROR "loop|interface" } type I2 interface { I1 // GC_ERROR "loop|interface" } ...
Go
// $G $D/$F.go && $L $F.$A && ./$A.out // 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 main func Alloc(i int) int { switch i { default: return 5; case 1: return 1; case 10: return 10; } ...
Go