Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1289)

Delta Between Two Patch Sets: src/pkg/go/build/cgotest/file.go

Issue 4433047: code review 4433047: go/build: new package for building go programs (Closed)
Left Patch Set: diff -r b7ac8e05d187 https://go.googlecode.com/hg/ Created 13 years, 10 months ago
Right Patch Set: diff -r d9401fa9dc01 https://go.googlecode.com/hg/ Created 13 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/go/build/build_test.go ('k') | src/pkg/go/build/dir.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 /*
6 A trivial example of wrapping a C library in Go.
7 For a more complex example and explanation,
8 see ../gmp/gmp.go.
9 */
10
11 package stdio
12
13 /*
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <sys/stat.h>
17 #include <errno.h>
18
19 char* greeting = "hello, world";
20 */
21 import "C"
22 import "unsafe"
23
24 type File C.FILE
25
26 var Stdout = (*File)(C.stdout)
27 var Stderr = (*File)(C.stderr)
28
29 // Test reference to library symbol.
30 // Stdout and stderr are too special to be a reliable test.
31 var myerr = C.sys_errlist
32
33 func (f *File) WriteString(s string) {
34 p := C.CString(s)
35 C.fputs(p, (*C.FILE)(f))
36 C.free(unsafe.Pointer(p))
37 f.Flush()
38 }
39
40 func (f *File) Flush() {
41 C.fflush((*C.FILE)(f))
42 }
43
44 var Greeting = C.GoString(C.greeting)
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b