code
stringlengths
10
1.34M
language
stringclasses
1 value
// 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. // This file contains the code snippets included in "Defer, Panic, and Recover." package main import ( "fmt" "io" "os" ) func a() { i := 0 defer fmt.Pri...
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. // This file contains the code snippets included in "The Laws of Reflection." package main import ( "bufio" "bytes" "io" "os" ) type MyInt int var i int...
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 ( "fmt" "image" ) func main() { r := image.Rect(2, 1, 5, 5).Add(image.Pt(-4, -2)) fmt.Println(r.Dx(), r.Dy(), image.Pt(0, 0).In(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" "sort" ) func main() { seq := Sequence{6, 2, -1, 44, 16} sort.Sort(seq) fmt.Println(seq) } type Sequence []int // Methods 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 main import ( "fmt" "image" ) func main() { p := image.Point{2, 1} fmt.Println("X is", p.X, "Y is", p.Y) }
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 query type Conn string func (c Conn) DoQuery(query string) Result { return Result("result") } type Result string func Query(conns []Conn, query stri...
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 rand2 /* #include <stdlib.h> */ import "C" func Random() int { var r C.long = C.random() return int(r) } // STOP OMIT func Seed(i int) { C.srandom(...
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 rand /* #include <stdlib.h> */ import "C" // STOP OMIT func Random() int { return int(C.random()) } // STOP OMIT func Seed(i int) { C.srandom(C.uint...
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 ( "fmt" "image" ) func main() { r := image.Rect(2, 1, 5, 5) // Dx and Dy return a rectangle's width and height. fmt.Println(r.Dx(), r...
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" "encoding/gob" "fmt" "log" ) type P struct { X, Y, Z int Name string } type Q struct { X, Y *int32 Name string } fu...
Go
// 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. // Test that top-level parenthesized declarations can be empty. // Compiles but does not run. package P import ( ) const ( ) var ( ) type ( )
Go
// run // 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. // Test that dynamic interface checks treat byte=uint8 // and rune=int or rune=int32. package main func main() { var x interface{} x = byte(1) sw...
Go
// $G $D/method4a.go && $G $D/$F.go && $L $F.$A && ./$A.out // 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. // Test method expressions with arguments. package main import "./method4a" type T1 int type T2...
Go
// run // 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. // Test that zero division causes a panic. package main import ( "fmt" "math" "runtime" "strings" ) type ErrorTest struct { name string fn fu...
Go
// run // 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. // Test range over strings. package main import ( "fmt" "os" "unicode/utf8" ) func main() { s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U001...
Go
// errorcheck // 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. // Verify that method redeclarations are caught by the compiler. // Does not compile. package main type T struct { } func (t *T) M(int, string)...
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
// $G $D/$F.go && $L -X main.tbd hello $F.$A && ./$A.out // 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. // Test the -X facility of the gc linker (6l etc.). package main var tbd string func main() { if ...
Go
// errorcheck // 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. // Verify that various erroneous type switches are caught be the compiler. // Does not compile. package main import "io" func whatis(x interfa...
Go
// run // 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. // Test if statements in various forms. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail", m...
Go
// run // 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. // Test that returning &T{} from a function causes an allocation. package main type T struct { int } func f() *T { return &T{1} } func main() { ...
Go
// run // 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. // Test recovering from runtime errors. package main import ( "runtime" "strings" ) var didbug bool func bug() { if didbug { return } printl...
Go
// run // 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. // Test static interface conversion of interface value nil. package main type R interface { R() } type RW interface { R(); W() } var e interface {} v...
Go
// 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 recursive type I1 interface { foo() I2 } type I2 interface { bar() I1 } type T int func (t T) f...
Go
// run // 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. // Test interface values containing structures. package main import "os" var fail int func check(b bool, msg string) { if (!b) { println("failure...
Go
// errorcheck // 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. // Test methods derived from embedded interface and *interface values. package main import "os" const Value = 1e12 type Inter interface { M()...
Go
// skip # used by recursive2 // 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. // Mutually recursive type definitions imported and used by recursive1.go. package p type I1 interface { F() I2 } type I2 int...
Go
// run // 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. // Test interface comparisons using types hidden // inside reflected-on structs. package main import "reflect" type T struct { F float32 G float32 ...
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. // Test that unexported methods are not visible outside the package. // Does not compile. package main import "./priv...
Go
// run // 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. // Test all the different interface conversion runtime functions. package main type Stringer interface { String() string } type StringLengther interf...
Go
// errorcheck // 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. // Test that interface{M()} = *interface{M()} produces a compiler error. // Does not compile. package main type Inst interface { Next() *Inst ...
Go
// errorcheck // 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. // Verify compiler messages about erroneous static interface conversions. // Does not compile. package main type T struct { a int } var t *T ...
Go
// run // 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. // Test methods derived from embedded interface values. package main import "os" const Value = 1e12 type Inter interface { M() int64 } type T int64...
Go
// run // 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. // Test static interface conversion of interface value nil. package main type R interface { R() } type RW interface { R(); W() } var e interface {} v...
Go
// $G $D/recursive1.go && $G $D/$F.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. // Test that the mutually recursive types in recursive1.go made it // intact and with the same meaning, by assigning to ...
Go
// errorcheck // 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. // Verify compiler complains about missing implicit methods. // Does not compile. package main type T int func (t T) V() func (t *T) P() type...
Go
// run // 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. // Test that interface conversion fails when method is missing. package main type I interface { Foo() } func main() { shouldPanic(p1) } func p1() ...
Go
// run // 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. // Test Implicit methods for embedded types and // mixed pointer and non-pointer receivers. package main type T int var nv, np int func (t T) V() { ...
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. // Test that embedded interface types can have local methods. package main import "./embed0" type ...
Go
// run // 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. // Test interface methods with different return types are distinct. package main type S struct { a int } type T struct { b string } func (s *S) Name(...
Go
// skip # 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. // Imported by private.go, which should not be able to see the private method. package p type Exported interface { private() } ...
Go
// run // 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. // Test big vs. small, pointer vs. value interface methods. package main type I interface { M() int64 } type BigPtr struct { a, b, c, d int64 } func ...
Go
// skip # 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. // Test that embedded interface types can have local methods. package p type T int func (t T) m() {} type I interface { m() } ty...
Go
// run // 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. // Test run-time error detection for interface values containing types // that cannot be compared for equality. package main func main() { cmp(1) ...
Go
// errorcheck // 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. // Verify that renamed identifiers no longer have their old meaning. // Does not compile. package main func main() { var n byte // ERRO...
Go
// errorcheck // 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. // Verify goto semantics. // Does not compile. // // Each test is in a separate function just so that if the // compiler stops processing after ...
Go
// run // 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. // Test basic operation of finalizers. package main import ( "runtime" "time" ) const N = 250 type A struct { b *B n int } type B struct { n i...
Go
// run // 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. // Simple test of the garbage collector. package main import "runtime" func mk2() { b := new([10000]byte) _ = b // println(b, "stored at", &b) } ...
Go
// run // 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. // Solve the 2,3,5 problem (print all numbers with 2, 3, or 5 as factor) using channels. // Test the solution, silently. package main type T chan uint...
Go
// skip // 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. // Run runs tests in the test directory. // // TODO(bradfitz): docs of some sort, once we figure out how we're changing // headers of files package m...
Go
// errorcheck // 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. // Verify that incorrect comparisons are detected. // Does not compile. package main func use(bool) {} type T1 *int type T2 *int type T3 stru...
Go
// run // 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. // Test string literal syntax. package main import "os" var ecode int func assert(a, b, c string) { if a != b { ecode = 1 print("FAIL: ", c, ":...
Go
// run // 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 // Test for correct heap-moving of escaped variables. // It is hard to check for the allocations, but it is easy // to check that if you c...
Go
// errorcheck // 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. // Verify that incorrect invocations of the complex predeclared function are detected. // Does not compile. package main var ( f32 float32 f6...
Go
// errorcheck // 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. // Test that incorrect short declarations and redeclarations are detected. // Does not compile. package main func f1() int {...
Go
// true // 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 // can't use local path with -u, use -I. instead import "pkg" // ERROR "import unsafe package" func main() { print(pkg.Float32bits(1.0...
Go
// $G $D/pkg.go && pack grc pkg.a pkg.$A 2> /dev/null && rm pkg.$A && errchk $G -I. -u $D/main.go // rm -f pkg.a // 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 ignored
Go
// true // 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. // a package that uses unsafe on the inside but not in it's api package pkg import "unsafe" // this should be inlinable func Float32bits(f float32) ...
Go
// $G $D/pkg.go && pack grcS pkg.a pkg.$A 2> /dev/null && rm pkg.$A && $G -I. -u $D/main.go // rm -f pkg.a // 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 ignored
Go
// 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. // Test that types can be parenthesized. package main func f(interface{}) func g() {} func main() { f(map[string]string{"a":"b","c":"d"}) f([......
Go
// 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. 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 string...
Go
// run // 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 := x[f():f()] if len(y) != 1 || ...
Go
// run // 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 "os" func main() { x := 4 a, b, c, d := func(i int) (p int, q int, r int, s int) { return 1, i, 3, x }(2) if a != 1 || b != 2 ...
Go
// run // 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:13: fatal error: goc: exit 1 */
Go
// build // 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) } /* main·f: doasm: notfound from=75 to=13 ...
Go
// errorcheck // 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 converting constant ...
Go
// run // 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. // Issue 2582 package main type T struct{} func (T) cplx() complex128 { for false { } // avoid inlining return complex(1, 0) } func (T) cplx2() c...
Go
// errorcheck // 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
// errorcheck // 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. // Issue 2598 package foo return nil // ERROR "non-declaration statement outside function body|expected declaration"
Go
// run // 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 := T{s, f} type M map[int]int ...
Go
// run // 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 // Test that structures pack densely, according to the alignment of the largest field. package main import ( "fmt" "os" "strconv" ) type T1 struct ...
Go
// 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. package main const s string = "foo"; func main() { i := len(s); // should be legal to take len() of a constant _ = i; } /* uetli:~/Source/go1/...
Go
// errorcheck // 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 should be rep...
Go
// compile // 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(a[3]...
Go
// run // 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() string { return "int"; } func main...
Go
// run // 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
// 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. package bug232 type I interface { X(...int) }
Go
// 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. package bug063 const c = 0 ^ 0
Go
// errorcheck // 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 // dropped dur...
Go
// errorcheck // 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. // Issue 2627 -- unsafe.Pointer type isn't handled nicely in some errors package main import "unsafe" func main() { var x *int _ = unsafe.Po...
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 "./p1" type MyObject struct { p1.Fer } func main() { var b p1.Fer = &p1.Object{} p1.PrintFer(b) va...
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 p1 import "fmt" type Fer interface { f() string } type Object struct {} func (this *Object) f() string { return "Ob...
Go
// run // 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) {} func main() { { var i in...
Go
// errorcheck // 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 // ERROR "loop|interface" } var i1 I1...
Go
// run // 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; } return 0 } func main() { s :=...
Go
// run // 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" type S struct { i int } func (p *S) Get() int { return p.i } type Empty interface { } type Getter interface { Get() int; }...
Go
// 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. package main func f(a int64) int64 { const b int64 = 0; n := a &^ b; return n; } func main() { f(1) } /* bug156.go:7: constant 18446744073709...
Go
// run // 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 g() {} func f1() (a, b int) { a, b = 2, 1 g() // defeat optimizer return a, b } func f2() (a, b int) { a, b = 1, 2 g() // defe...
Go
// errorcheck // 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. // This is a test case for issue 804. package main func f() [10]int { return [10]int{} } var m map[int][10]int func main() { f()[1] = 2 //...
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 "./p" func main() {} var _ p.A
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 p type A struct { s struct{int} } func (a *A) f() { a.s = struct{int}{0} }
Go
// 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. package bug150 type T int func (t T) M() type M interface { M() } func g() (T, T) func f() (a, b M) { a, b = g(); return; } /* bugs/bug150.g...
Go
// 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. // Test case for issue 475. This file should compile. package main import . "unsafe" func main() { var x int println(Sizeof(x)) } /* bug239.go...
Go
// build // 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() { exit: ; goto exit } func main() { exit: ; // this should be legal (labels not properly scoped?) goto exit } /* uetli:~...
Go
// run // 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() { L: for i := 0; i < 1; i++ { L1: for { break L } panic("BUG: not reached - break") if false { goto L1 } } ...
Go
// errorcheck // 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. // RESOLUTION: This program is illegal. We should reject all unnecessary backslashes. package main const c = '\''; // this works const s = "\...
Go
// errorcheck // 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 func f() (_ int, err error) { return } func g() (x int, _ error) { return } func h() (_ int, _ error) { return } func i() (int,...
Go
// run // 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 frexp() (a int, b float64) { return 1, 2.0 } func main() { a, b := frexp(); _, _ = a, b; } /* bug056.go:8: illegal types for ope...
Go
// compile // 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. // Issue 2576 package bug type T struct { a int } func f(t T) { switch _, _ = t.a, t.a; {} }
Go