Skip to content

Instantly share code, notes, and snippets.

@GeertJohan
Created June 10, 2013 06:18
Show Gist options
  • Save GeertJohan/5746853 to your computer and use it in GitHub Desktop.
Save GeertJohan/5746853 to your computer and use it in GitHub Desktop.
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