Closed
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go1.10.3
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env
)?
linux/amd64
What did you do?
package main
/*
#include <stdio.h>
#include <stdlib.h>
void printString(const char* s) {
printf("%s", s);
}
*/
import "C"
import "unsafe"
func printString(s string) {
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
C.printString(cs)
}
func main() {
s := "hello"
printString(s)
}
What did you expect to see?
hello
What did you see instead?
I did not see anything. However, if I replace
printf("%s", s);
by
printf("%s\n", s);
It works.