code
stringlengths
10
1.34M
language
stringclasses
1 value
// 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 goto and labels. package main func main() { i := 0 if false { goto gogoloop } if false { goto gogoloop } if false { goto gogoloop ...
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 simple arithmetic and assignment for complex numbers. package main const ( R = 5 I = 6i C1 = R + I // ADD(5,6) ) func main() { var b boo...
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 operations on bool. package main type s struct { a bool; b bool; } func main() { var a,b bool; a = true; b = false; if !a { pan...
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 general operation using a list implementation. package main type Item interface { Print() string } type ListItem struct { item Item next *...
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 struct-valued variables (not pointers). package main type x2 struct { a,b,c int; d int; }; var g1 x2; var g2 struct { a,b,c int; d x2; }; fun...
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 composite literals. package main type M map[int]int type S struct{ a,b,c int }; type SS struct{ aa,bb,cc S }; type SA struct{ a,b,c [3]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 composition, decomposition, and reflection on complex numbers. package main import "unsafe" import "reflect" const ( R = 5 I = 6i C1 = R ...
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 interfaces and methods. package main type S struct { a,b int; } type I1 interface { f ()int; } type I2 interface { g() int; f() 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 simple function literals. package main func main() { x := func(a int)int { x := func(a int)int { x := func(a int)int { return a+5; ...
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 interfaces on basic types. package main type myint int type mystring string type I0 interface{} func f() { var ia, ib I0 var i myint var 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. // Test simple arithmetic conversion. package main type vlong int64 type short int16 func main() { s1 := vlong(0) for i := short(0); i < 10; i = 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. // Test method invocation with pointer receivers and function-valued fields. package main type C struct { a int; x func(p *C)int; } func (this *C) ...
Go
// cmpout // 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 operations including printing. package main func main() { var c string a := `abc` b := `xyz` /* print a literal */ print(`abc...
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 assignment. package main type Iputs interface { puts (s string) string; } // --------- type Print struct { whoami int; put Iput...
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 for loops of many forms. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail" + msg + "...
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. // Test method expressions with arguments. // This file is not tested by itself; it is imported by method4.go. package method4a type T1 int type T2 ...
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 simultaneous assignment. package main var a, b, c, d, e, f, g, h, i int func printit() { println(a, b, c, d, e, f, g, h, i) } func testit(p...
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 evaluation order in if condition. package main var calledf = false func f() int { calledf = true return 1 } func g() int { if !calledf {...
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 the cap predeclared function applied to channels. package main func main() { c := make(chan int, 10) if len(c) != 0 || cap(c) != 10 { prin...
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 erroneous initialization expressions are caught by the compiler // Does not compile. package main type S struct { A, B, C, X, Y...
Go
// errchk -0 $G -m -l $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, using compiler diagnostic flags, that bounds check elimination // is eliminating the correct checks. package foo var...
Go
// cmpout // 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 we can defer the predeclared functions print and println. package main func main() { defer println(42, true, false, true, 1.5, "worl...
Go
// errchk -0 $G -m -l $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. // Test, using compiler diagnostic flags, that the escape analysis is working. // Compiles but does not run. Inlining is disab...
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 and explicit conversions of constants. package main const ( ci8 = -1 << 7 ci16 = -1<<15 + 100 ci32 = -1<<31 + 100000 ci64 = -1<<...
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 that illegal conversions involving strings are detected. // Does not compile. package main type Tbyte []byte type Trune []rune type ...
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. // Test map declarations of many types, including erroneous ones. // Does not compile. package main func main() {} type v bool var ( // val...
Go
// [ "$GOOS" == windows ] || // ($G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.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 a program can survive SIGCHLD. package main import ...
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 various safe uses of indirection. package main var m0 map[string]int var m1 *map[string]int var m2 *map[string]int = &m0 var m3 map[string]int...
Go
// cmpout // 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 println can be the target of a go statement. package main import "time" func main() { go println(42, true, false, true, 1.5, "world...
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 that erroneous labels are caught by the compiler. // This set is caught by pass 1. // Does not compile. package main var x int func...
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 of recover during recursive panics. // Here be dragons. package main import "runtime" func main() { test1() test2() test3() test4() tes...
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 defer. package main import "fmt" var result string func addInt(i int) { result += fmt.Sprint(i) } func test1helper() { for i := 0; i < 10;...
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 simple type switches on basic types. package main import "fmt" const ( a = iota b c d e ) var x = []int{1, 2, 3} func f(x int, len *by...
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 simple boolean and numeric constants. package main const ( c0 = 0 cm1 = -1 chuge = 1 << 100 chuge_1 = chuge - 1 c1 = chuge >> 100 c3div2...
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 iota. package main func assert(cond bool, msg string) { if !cond { print("assertion fail: ", msg, "\n") panic(1) } } const ( x int = 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. // Test stack splitting code. // Try to tickle stack splitting bugs by doing // go, defer, and closure calls at different stack depths. package main t...
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 a couple of illegal variable declarations are caught by the compiler. // Does not compile. package main func main() { _ = asdf...
Go
// $G -S $D/$F.go | egrep initdone >/dev/null && echo BUG sinit || true // 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 many initializations can be done at link time and // generate no executab...
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 divide corner cases. package main import "fmt" func f8(x, y, q, r int8) { if t := x / y; t != q { fmt.Printf("%d/%d = %d, want %d\n", x, ...
Go
// $G $D/$F.go && $L $F.$A && // ./$A.out >tmp.go && $G tmp.go && $L -o $A.out1 tmp.$A && ./$A.out1 // rm -f tmp.go $A.out1 // 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. // Generate test of shift and rota...
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 reordering of assignments. package main import "fmt" func main() { p1() p2() p3() p4() p5() p6() p7() p8() p9() } var gx []int fu...
Go
// skip // 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 file is compiled and then imported by ddd3.go. package ddd func Sum(args ...int) int { s := 0 for _, v := range args { s += v } return...
Go
// run cmplxdivide1.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. // Driver for complex division table defined in cmplxdivide1.go package main import ( "fmt" "math" "math/cmplx" ) type Test struc...
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 floating-point literal syntax. package main var bad bool func pow10(pow int) float64 { if pow < 0 { return 1 / pow10(-pow) } if pow > 0 ...
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 func main() { for var x = 0; x < 10; x++ { // ERROR "var declaration not allowed in for initializer"
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 main func x() { } func main() { if { // ERROR "missing condition" } if x(); { // ERROR "missing condition" } }
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 fmt.Printf("hello") // ERROR "non-declaration statement outside function body|expected declaration" func main() { } x++ // ERROR...
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 var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|expected ';' or newline after top level declaration" ...
Go
// errorcheck // 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 var a = []int{ 3 // ERROR "need trailing comma before newline in composite literal" }
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 func main() { var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|expected ';' or '}' or newline"
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 T // ERROR "unexpected semicolon or newline in type declaration" {
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 func main() { for x // GCCGO_ERROR "undefined" { // ERROR "unexpected semicolon or newline before .?{.?" z // GCCGO_ERROR "u...
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 import ( "io", // ERROR "unexpected comma" "os" )
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 func main() { if x; y // ERROR "unexpected semicolon or newline before .?{.?|undefined" { z // GCCGO_ERROR "undefined"
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 var c chan int var v int func main() { if c <- v { // ERROR "send statement.*value.*select" } } var _ = c <- v // ERROR "send ...
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 func main() { // ERROR "unexpected semicolon or newline before .?{.?"
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 xyz struct { ch chan } // ERROR "unexpected .*}.* in channel type" func Foo(y chan) { // ERROR "unexpected .*\).* in cha...
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 func main() { for x; y; z // ERROR "unexpected semicolon or newline before .?{.?|undefined" { z // GCCGO_ERROR "undefined"
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 main func main() { if true { } else ; // ERROR "else must be followed by if or statement block|expected .if. or .{." }
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 T interface { f, g () // ERROR "name list not allowed in interface type" }
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 main func main() { switch main() := interface{}(nil).(type) { // ERROR "invalid variable name" default: } }
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 func main() { switch x; y // ERROR "unexpected semicolon or newline before .?{.?|undefined" { z
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 func main() { if x { } // GCCGO_ERROR "undefined" else { } // ERROR "unexpected semicolon or newline before .?else.?" }
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 result parameters are in the same scope as regular parameters. // Does not compile. package main func f1(a int) (int, float32) { ...
Go
// errchk -0 $G -m $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. // Test, using compiler diagnostic flags, that the escape analysis is working. // Compiles but does not run. Inlining is enabled....
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 uses of the blank identifer are caught. // Does not compile. package _ // ERROR "invalid package name _" 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. // Semi-exhaustive test for the copy predeclared function. package main import ( "fmt" "os" ) const N = 40 var input8 = make([]uint8, N) var outpu...
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 illegal uses of composite literals are detected. // Does not compile. package main var a = []int { "a" }; // ERROR "conver|incom...
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. // Test that a comment ending a source file does not need a final newline. // Compiles but does not run. package eof1 // No newline at the end of...
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 that erroneous labels are caught by the compiler. // This set is caught by pass 2. That's why this file is label1.go. // Does not com...
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 maps, almost exhaustively. package main import ( "fmt" "math" "strconv" "time" ) const count = 100 func P(a []string) string { 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. // Test correct short declarations and redeclarations. package main func f1() int { return 1 } func f2() (float32, int) { r...
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 concurrency primitives: classical inefficient concurrent prime sieve. // Generate primes up to 100 using channels, checking the results. // Thi...
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 for select: Issue 2075 // A bug in select corrupts channel queues of failed cases // if there are multiple waiters on those channels and the //...
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. // Torture test for goroutines. // Make a lot of goroutines, threaded together, and tear them down cleanly. package main import ( "os" "strconv" ) ...
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 unbuffered channels act as pure fifos. package main import "os" const N = 10 func AsynchFifo() { ch := make(chan int, N) for i := 0; ...
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 the semantics of the select statement // for basic empty/non-empty cases. package main import "time" const always = "function did not" const ...
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 concurrency primitives: power series. // Power series package // A power series is a channel, along which flow rational // coefficients. A den...
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 channel operations that test for blocking. // Use several sizes and types of operands. package main import "runtime" import "time" func i32re...
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 concurrency primitives: prime sieve of Eratosthenes. // Generate primes up to 100 using channels, checking the results. // This sieve is Eratos...
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 select when discarding a value. package main import "runtime" func recv1(c <-chan int) { <-c } func recv2(c <-chan int) { select { case ...
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 various parsing cases that are a little // different now that send is a statement, not a expression. package main func main() { chanchan() ...
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 a select statement proceeds when a value is ready. package main func f() *int { println("BUG: called f") return new(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. // Test simple select. package main var counter uint var shift uint func GetValue() uint { counter++ return 1 << shift } func Send(a, b chan uint)...
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 selects do not consume undue memory. package main import "runtime" func sender(c chan int, n int) { for i := 0; i < n; i++ { c <- 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. // Test making channels of a zero-sized type. package main func main() { _ = make(chan [0]byte) _ = make(chan [0]byte, 1) _ = make(chan struct{}) ...
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 the situation in which two cases of a select can // both end up running. See http://codereview.appspot.com/180068. package main import ( "fla...
Go
// runoutput // 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. // Generate test of channel operations and simple selects. // The output of this program is compiled and run to do the // actual test. // Each t...
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 various correct and incorrect permutations of send-only, // receive-only, and bidirectional channels. // Does not compile. package 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. // Test concurrency primitives: power series. // Like powser1.go but uses channels of interfaces. // Has not been cleaned up as much as powser1.go, to ...
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 simple functions. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail", msg, "\n") pa...
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 equality and inequality operations. package main import "unsafe" var global bool func use(b bool) { global = b } func stringptr(s string) ui...
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 composite literals. package main type T struct { i int f float64 s string next *T } type R struct { num int } func itor(a int)...
Go
// $G $D/ddd2.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. // Test that variadic functions work across package boundaries. package main import "./ddd2" func m...
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 that illegal composite literals are detected. // Does not compile. package main var m map[int][3]int func f() [3]int func fp() *[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. // Test var x = x + 1 works. package main func main() { var x int = 1 if x != 1 { print("found ", x, ", expected 1\n") panic("fail") } { var...
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 illegal character literals are detected. // Does not compile. package main const ( // check that surrogate pair elements are in...
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 simple type switches, including chans, maps etc. package main import "os" const ( Bool = iota Int Float String Struct Chan Array Map ...
Go
// cmpout // 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 we can do page 1 of the C book. package main func main() { print("hello, world\n") }
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 invalid imports are rejected by the compiler. // Does not compile. package main // Correct import paths. import _ "fmt" import _...
Go