github.com/yukk001/go1.10.8@v0.0.0-20190813125351-6df2d3982e20/doc/progs/cgo4.go (about) 1 // Copyright 2012 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 package print 6 7 // #include <stdio.h> 8 // #include <stdlib.h> 9 import "C" 10 import "unsafe" 11 12 func Print(s string) { 13 cs := C.CString(s) 14 defer C.free(unsafe.Pointer(cs)) 15 C.fputs(cs, (*C.FILE)(C.stdout)) 16 } 17 18 // END OMIT