Beispiel #1
0
// GetString is used to get string config values.
//
// The format of the configuration parameter is the same as in GetBool.
func (c *Config) GetString(name string) (string, error) {
	var v *C.char
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	if C.git_config_get_string(&v, c.config, cname) != C.GIT_OK {
		return "", lastErr()
	}
	return C.GoString(v), nil
}
Beispiel #2
0
func (cfg *Config) GetString(name string) (string, error) {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	// TODO: Is there a better way to pass a string pointer to C?
	var val [1]int8
	cval := (*C.char)(&val[0])
	ecode := C.git_config_get_string(&cval, cfg.git_config, cname)
	if ecode != git_SUCCESS {
		return "", gitError()
	}
	return C.GoString(cval), nil
}
Beispiel #3
0
func (c *Config) LookupString(name string) (v string, err error) {
	var ptr *C.char
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	ret := C.git_config_get_string(&ptr, c.ptr, cname)
	if ret < 0 {
		return "", LastError()
	}

	return C.GoString(ptr), nil
}
Beispiel #4
0
func (c *Config) LookupString(name string) (string, error) {
	var ptr *C.char
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	if ret := C.git_config_get_string(&ptr, c.ptr, cname); ret < 0 {
		return "", MakeGitError(ret)
	}

	return C.GoString(ptr), nil
}