Exemplo n.º 1
0
func (h *HatTrie) Get(key string) bool {
	h.l.RLock()
	defer h.l.RUnlock()

	ckey := C.CString(key)
	defer C.free(unsafe.Pointer(ckey))
	val := C.get(h.trie, ckey, C.size_t(len(key)))
	return val == 1
}
Exemplo n.º 2
0
func Get(k *string) (v string, err error) {
	var v_len C.size_t

	key := C.CString(*k)
	defer C.free(unsafe.Pointer(key))

	val := C.get(key, C.size_t(len(*k)), &v_len)
	if val == nil {
		err = NotExist
		return
	}
	defer C.leveldb_free(unsafe.Pointer(val))

	v = C.GoStringN(val, C.int(v_len))
	return
}
Exemplo n.º 3
0
// Get returns the username and secret to use for a given registry server URL.
func (h Secretservice) Get(serverURL string) (string, string, error) {
	if serverURL == "" {
		return "", "", errors.New("missing server url")
	}
	var username *C.char
	defer C.free(unsafe.Pointer(username))
	var secret *C.char
	defer C.free(unsafe.Pointer(secret))
	server := C.CString(serverURL)
	defer C.free(unsafe.Pointer(server))

	err := C.get(server, &username, &secret)
	if err != nil {
		defer C.g_error_free(err)
		errMsg := (*C.char)(unsafe.Pointer(err.message))
		return "", "", errors.New(C.GoString(errMsg))
	}
	user := C.GoString(username)
	pass := C.GoString(secret)
	if pass == "" {
		return "", "", credentials.NewErrCredentialsNotFound()
	}
	return user, pass, nil
}
Exemplo n.º 4
0
func Issue8148() int {
	return int(C.get())
}
Exemplo n.º 5
0
func main() {
	mylog := C.get()

	fmt.Println(reflect.TypeOf(&mylog))

}