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 arrays and slices. package main func setpd(a []int) { // print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n"); for i := 0; i < len(a...
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 for loop. package main func main() { var t,i int; for i=0; i<100; i=i+1 { t = t+i; } if t != 50*99 { panic(t); } }
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 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 arithmetic on complex numbers, including multiplication and division. package main const ( R = 5 I = 6i C1 = R + I // ADD(5,6) C2 = 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 simple operations on arrays. package main var b[10] float32; func main() { var a[10] float32; for i:=int16(5); i<10; i=i+1 { a[i] = floa...
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 switch. package main func main() { r := "" a := 3 for i := 0; i < 10; i = i + 1 { switch i { case 5: r += "five" case a, 7:...
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 functions of many signatures. package main func assertequal(is, shouldbe int, msg string) { if is != shouldbe { print("assertion fail" + ms...
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 goto and labels. package main func main() { i := 0 if false { goto gogoloop } if false { goto gogoloop } if false { goto gogoloop ...
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 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 embedded fields of structs, including methods. package main type I interface { test1() int test2() int test3() int test4() int test5() 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 'for range' on arrays, slices, and maps. package main const size = 16 var a [size]byte var p []byte var m map[int]byte func f(k int) byte { ...
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 shift. package main var ians [18]int; var uans [18]uint; var pass string; func testi(i int, t1,t2,t3 int) { n := ((t1*3) + t2)*2 + t3; if 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 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
// [ "$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
// 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
// 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
// skip # used by import3 // 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. // Various declarations of exported variables and functions. // Imported by import3.go. package p var C1 chan <- chan int = (chan<...
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 import conflicts are detected by the compiler. // Does not compile. package main import "bufio" // GCCGO_ERROR "previous|not use...
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
// 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
// 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
// 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 the run-time behavior of escape analysis-related optimizations. package main func main() { test1() } func test1() { check1(0) check1(1) ...
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 close(c), receive of closed channel. // // TODO(rsc): Doesn't check behavior of close(c) when there // are blocked senders/receivers. package 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 floating-point comparison involving NaN. package main import "math" type floatTest struct { name string expr bool want bool } var nan flo...
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
// 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 literal syntax for basic types. package main var nbad int func assert(cond bool, msg string) { if !cond { if nbad == 0 { print("BUG") ...
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 reorderings; derived from fixedbugs/bug294.go. package main var log string type TT int func (t TT) a(s string) TT { log += "a(" + s + ")" ...
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 defer. package main import "fmt" var result string func addInt(i int) { result += fmt.Sprint(i) } func test1helper() { for i := 0; i < 10;...
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
// 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 the implementation catches nil ptr indirection // in a large address space. package main import "unsafe" // Having a big address space ...
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 on slices. package main type T []int func (t T) Len() int { return len(t) } type I interface { Len() int } func main() { var t T ...
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 for run-time errors. // TODO(rsc): // null pointer accesses package main import "strings" var x = make([]byte, 10) 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 that the Go environment variables are present and accessible through // package os and package runtime. package main import ( "os" "runtime"...
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
// 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
// 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 basic operations on named types are valid // and preserve the type. // Does not compile. package main type Bool bool type Map ma...
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 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
// 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 illegal shifts. // Issue 1708, illegal cases. // Does not compile. package p func f(x int) int { return 0 } func g(x interface...
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 assignment rules are enforced by the compiler. // Does not compile. package main type ( A [10]int B []int C chan int F func() 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 of basic recover functionality. package main import "runtime" func main() { test1() test1WithClosures() test2() test3() test4() test5(...
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. // Test the 'for range' construct. package main // test range over channels func gen(c chan int, lo, hi int) { for i := lo; i <= hi; i++ { c <- i ...
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
// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go && // $G tmp.go && $L tmp.$A && ./$A.out || echo BUG: 64bit // rm -f tmp.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. // Generate test of 64-bit arithmeti...
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
// 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
// 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 indirection are caught by the compiler. // Does not compile. package main var m0 map[string]int var m1 *map[stri...
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
// [ "$GORUN" == "" ] || exit 0 # Android runner gets confused by the NUL output // $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go && // errchk $G -e tmp.go // rm -f tmp.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 LI...
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
// 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 big numbers work as constants and print can print them. package main func main() { print(-(1<<63), "\n") print((1<<63)-1, "\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 allowed and disallowed conversions. // Does not compile. package main // everything here is legal except the ERROR line var c chan i...
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
// 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 behavior of maps with large elements. package main func seq(x, y int) [1000]byte { var r [1000]byte for i := 0; i < len(r); i++ { r[i] = b...
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 static interface conversion of interface value nil. package main type R interface { R() } type RW interface { R(); W() } var e interface {} v...
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
// $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
// 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
// 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 static interface conversion of interface value nil. package main type R interface { R() } type RW interface { R(); W() } var e interface {} v...
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 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
// 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
// $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 all the different interface conversion runtime functions. package main type Stringer interface { String() string } type StringLengther interf...
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 interface comparisons using types hidden // inside reflected-on structs. package main import "reflect" type T struct { F float32 G float32 ...
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 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
// 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
// $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
// 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
// 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
// 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
// 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
// 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
// $G $D/empty.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. // Verify that various kinds of "imported and not used" // errors are caught by the compiler. // Does not compile. pac...
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 "swig/file" func main() { file.Puts("Hello, world") }
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 ( "fmt" "swig/callback" ) type GoCallback struct{} func (p *GoCallback) Run() string { return "GoCallback.Run" } func main() { c :=...
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/xml" "flag" "fmt" "io/ioutil" "log" "os" "path/filepath" "regexp" "runtime" "strconv" "strings" "time" ) ...
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/json" "errors" "fmt" "io" "log" "net/http" "net/url" "time" ) type obj map[string]interface{} // dash runs t...
Go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "bytes" "io" "log" "os" "os/exec" ) // run is a simple wrapper for exec.Run/Close func run(envv []string, dir string, argv ...strin...
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. /* Go Builder is a continuous build client for the Go project. It integrates with the Go Dashboard AppEngine application. Go Builder is intended to run conti...
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. // +build ignore package main import "../stdio" func main() { stdio.Stdout.WriteString(stdio.Greeting + "\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. /* A trivial example of wrapping a C library in Go. For a more complex example and explanation, see ../gmp/gmp.go. */ package stdio /* #include <stdio.h> #in...
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. // +build ignore // Compute Fibonacci numbers with two goroutines // that pass integers back and forth. No actual // concurrency, just threads and synchroniz...
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. // +build ignore // Pass numbers along a chain of threads. package main import ( "../stdio" "runtime" "strconv" ) const N = 10 const R = 5 func link(le...
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. // +build ignore // Run the game of life in C using Go for parallelization. package main import ( "." "flag" "fmt" ) const MAXDIM = 100 var dim = flag....
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 life // #include "life.h" import "C" import "unsafe" func Run(gen, x, y int, a []int) { n := make([]int, x*y) for i := 0; i < gen; i++ { C.Step(...
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. // This file contains test cases for cgo. package cgotest /* // issue 1222 typedef union { long align; } xxpthread_mutex_t; struct ibv_async_event { union...
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 cgotest // const char *greeting = "hello, world"; import "C" import ( "reflect" "testing" "unsafe" ) const greeting = "hello, world" type testPa...
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. // This file contains test cases for cgo. package cgotest /* int base_symbol = 0; #define alias_one base_symbol #define alias_two base_symbol */ import "C" ...
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. // Basic test cases for cgo. package cgotest /* #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <errno.h> #define SHIFT(x, y) ((x)<<(...
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 cgotest /* #include <windows.h> unsigned int sleep(unsigned int seconds) { Sleep(1000 * seconds); return 0; } */ import "C"
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 cgotest import "C" //export exportbyte func exportbyte() byte { return 0 } //export exportbool func exportbool() bool { return false } //export e...
Go