3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
8 A trivial example of wrapping a C library in Go.
9 For a more complex example and explanation,
21 char* greeting = "hello, world";
28 // Test reference to library symbol.
29 // Stdout and stderr are too special to be a reliable test.
32 func (f *File) WriteString(s string) {
34 C.fputs(p, (*C.FILE)(f))
35 C.free(unsafe.Pointer(p))
39 func (f *File) Flush() {
40 C.fflush((*C.FILE)(f))
43 var Greeting = C.GoString(C.greeting)
44 var Gbytes = C.GoBytes(unsafe.Pointer(C.greeting), C.int(len(Greeting)))