Created
June 10, 2013 06:18
-
-
Save GeertJohan/5746853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package linenoise | |
// +linux | |
// #include <stdlib.h> | |
// #include "linenoise.h" | |
import "C" | |
import ( | |
"unsafe" | |
) | |
// "fmt" | |
// Line displays given string and returns line from user input. | |
// char *linenoise(const char *prompt); | |
func Line(prompt string) string { | |
promptCString := C.CString(prompt) | |
resultCString, errno := C.linenoise(promptCString) | |
C.free(promptCString) | |
} | |
Error from go build: linenoise.go:19: cannot use promptCString (type *_Ctype_char) as type unsafe.Pointer in function argument | |
When changing line 19 to: | |
resultCString, errno := C.linenoise(unsafe.Pointer(promptCString)) | |
Errors: | |
linenoise.go:19: cannot use unsafe.Pointer(promptCString) (type unsafe.Pointer) as type *_Ctype_char in function argument | |
linenoise.go:19: cannot use promptCString (type *_Ctype_char) as type unsafe.Pointer in function argument |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment