Prechádzať zdrojové kódy

Update vendored dependencies

Signed-off-by: Jguer <me@jguer.space>
Jguer 6 rokov pred
rodič
commit
b10b88faf6

+ 2 - 2
Gopkg.lock

@@ -22,11 +22,11 @@
 
 [[projects]]
   branch = "master"
-  digest = "1:7681cb2a269451c1a0f781e1241ce0bd8e515d5e9a3b12f67fd768bafe08e682"
+  digest = "1:6eef31522b3a2349e9399c903ffa76c084c7fb9ef9d17a4e3da420649b0f5d17"
   name = "github.com/jguer/go-alpm"
   packages = ["."]
   pruneopts = "NUT"
-  revision = "39edc7671fa431a0d14ba6e023f5f2290a86333b"
+  revision = "643c287316a5456348cc689e1f2c980410e17d47"
 
 [[projects]]
   branch = "master"

+ 6 - 6
vendor/github.com/jguer/go-alpm/callbacks.go

@@ -31,26 +31,26 @@ func DefaultLogCallback(lvl LogLevel, s string) {
 	}
 }
 
-var log_callback logCallbackSig
-var question_callback questionCallbackSig
+var globalLogCallback logCallbackSig
+var globalQuestionCallback questionCallbackSig
 
 //export logCallback
 func logCallback(level C.alpm_loglevel_t, cstring *C.char) {
-	log_callback(LogLevel(level), C.GoString(cstring))
+	globalLogCallback(LogLevel(level), C.GoString(cstring))
 }
 
 //export questionCallback
 func questionCallback(question *C.alpm_question_t) {
 	q := (*C.alpm_question_any_t)(unsafe.Pointer(question))
-	question_callback(QuestionAny{q})
+	globalQuestionCallback(QuestionAny{q})
 }
 
 func (h *Handle) SetLogCallback(cb logCallbackSig) {
-	log_callback = cb
+	globalLogCallback = cb
 	C.go_alpm_set_logging(h.ptr)
 }
 
 func (h *Handle) SetQuestionCallback(cb questionCallbackSig) {
-	question_callback = cb
+	globalQuestionCallback = cb
 	C.go_alpm_set_question(h.ptr)
 }

+ 0 - 428
vendor/github.com/jguer/go-alpm/conf.go

@@ -1,428 +0,0 @@
-// conf.go - Functions for pacman.conf parsing.
-//
-// Copyright (c) 2013 The go-alpm Authors
-//
-// MIT Licensed. See LICENSE for details.
-
-package alpm
-
-import (
-	"bufio"
-	"bytes"
-	"fmt"
-	"io"
-	"os"
-	"reflect"
-	"strconv"
-	"strings"
-	"syscall"
-)
-
-type PacmanOption uint
-
-const (
-	ConfUseSyslog PacmanOption = 1 << iota
-	ConfColor
-	ConfTotalDownload
-	ConfCheckSpace
-	ConfVerbosePkgLists
-	ConfILoveCandy
-)
-
-var optionsMap = map[string]PacmanOption{
-	"UseSyslog":       ConfUseSyslog,
-	"Color":           ConfColor,
-	"TotalDownload":   ConfTotalDownload,
-	"CheckSpace":      ConfCheckSpace,
-	"VerbosePkgLists": ConfVerbosePkgLists,
-	"ILoveCandy":      ConfILoveCandy,
-}
-
-// PacmanConfig is a type for holding pacman options parsed from pacman
-// configuration data passed to ParseConfig.
-type PacmanConfig struct {
-	RootDir            string
-	DBPath             string
-	CacheDir           []string
-	HookDir            []string
-	GPGDir             string
-	LogFile            string
-	HoldPkg            []string
-	IgnorePkg          []string
-	IgnoreGroup        []string
-	Include            []string
-	Architecture       string
-	XferCommand        string
-	NoUpgrade          []string
-	NoExtract          []string
-	CleanMethod        []string
-	SigLevel           SigLevel
-	LocalFileSigLevel  SigLevel
-	RemoteFileSigLevel SigLevel
-	UseDelta           float64
-	Options            PacmanOption
-	Repos              []RepoConfig
-}
-
-// RepoConfig is a type that stores the signature level of a repository
-// specified in the pacman config file.
-type RepoConfig struct {
-	Name     string
-	SigLevel SigLevel
-	Usage    Usage
-	Servers  []string
-}
-
-// Constants for pacman configuration parsing
-const (
-	tokenSection = iota
-	tokenKey
-	tokenComment
-)
-
-type iniToken struct {
-	Type   uint
-	Name   string
-	Values []string
-}
-
-type confReader struct {
-	*bufio.Reader
-	Lineno uint
-}
-
-// newConfReader reads from the io.Reader if it is buffered and returns a
-// confReader containing the number of bytes read and 0 for the first line. If
-// r is not a buffered reader, a new buffered reader is created using r as its
-// input and returned.
-func newConfReader(r io.Reader) confReader {
-	if buf, ok := r.(*bufio.Reader); ok {
-		return confReader{buf, 0}
-	}
-	buf := bufio.NewReader(r)
-	return confReader{buf, 0}
-}
-
-func (rdr *confReader) ParseLine() (tok iniToken, err error) {
-	line, overflow, err := rdr.ReadLine()
-	switch {
-	case err != nil:
-		return
-	case overflow:
-		err = fmt.Errorf("line %d too long", rdr.Lineno)
-		return
-	}
-	rdr.Lineno++
-
-	line = bytes.TrimSpace(line)
-	if len(line) == 0 {
-		tok.Type = tokenComment
-		return
-	}
-	switch line[0] {
-	case '#':
-		tok.Type = tokenComment
-		return
-	case '[':
-		closing := bytes.IndexByte(line, ']')
-		if closing < 0 {
-			err = fmt.Errorf("missing ']' is section name at line %d", rdr.Lineno)
-			return
-		}
-		tok.Name = string(line[1:closing])
-		if closing+1 < len(line) {
-			err = fmt.Errorf("trailing characters %q after section name %s",
-				line[closing+1:], tok.Name)
-			return
-		}
-		return
-	default:
-		tok.Type = tokenKey
-		if idx := bytes.IndexByte(line, '='); idx >= 0 {
-			optname := bytes.TrimSpace(line[:idx])
-			values := bytes.Split(line[idx+1:], []byte{' '})
-			tok.Name = string(optname)
-			tok.Values = make([]string, 0, len(values))
-			for _, word := range values {
-				word = bytes.TrimSpace(word)
-				if len(word) > 0 {
-					tok.Values = append(tok.Values, string(word))
-				}
-			}
-		} else {
-			// boolean option
-			tok.Name = string(line)
-			tok.Values = nil
-		}
-		return
-	}
-}
-
-func ParseConfig(r io.Reader) (conf PacmanConfig, err error) {
-	rdr := newConfReader(r)
-	rdrStack := []confReader{rdr}
-	conf.SetDefaults()
-	confReflect := reflect.ValueOf(&conf).Elem()
-	var currentSection string
-	var curRepo *RepoConfig
-lineloop:
-	for {
-		line, err := rdr.ParseLine()
-		// fmt.Printf("%+v\n", line)
-		switch err {
-		case io.EOF:
-			// pop reader stack.
-			l := len(rdrStack)
-			if l == 1 {
-				break lineloop
-			}
-			rdr = rdrStack[l-2]
-			rdrStack = rdrStack[:l-1]
-		default:
-			break lineloop
-		case nil:
-			// Ok.
-		}
-
-		switch line.Type {
-		case tokenComment:
-		case tokenSection:
-			currentSection = line.Name
-			if currentSection != "options" {
-				conf.Repos = append(conf.Repos, RepoConfig{})
-				curRepo = &conf.Repos[len(conf.Repos)-1]
-				curRepo.Name = line.Name
-			}
-		case tokenKey:
-			switch line.Name {
-			case "SigLevel":
-				// TODO: implement SigLevel parsing.
-				continue lineloop
-			case "Usage":
-				for _, usage := range line.Values {
-					switch usage {
-					case "Sync":
-						curRepo.Usage |= UsageSync
-					case "Search":
-						curRepo.Usage |= UsageSearch
-					case "Install":
-						curRepo.Usage |= UsageInstall
-					case "Upgrade":
-						curRepo.Usage |= UsageUpgrade
-					case "All":
-						curRepo.Usage |= UsageAll
-					default:
-						err = fmt.Errorf("unknown option at line %d: %s", rdr.Lineno, line.Name)
-						break lineloop
-					}
-				}
-			case "Server":
-				curRepo.Servers = append(curRepo.Servers, line.Values...)
-				continue lineloop
-			case "Include":
-				conf.Include = append(conf.Include, line.Values[0])
-				f, err := os.Open(line.Values[0])
-				if err != nil {
-					err = fmt.Errorf("error while processing Include directive at line %d: %s",
-						rdr.Lineno, err)
-					break lineloop
-				}
-				rdr = newConfReader(f)
-				rdrStack = append(rdrStack, rdr)
-				continue lineloop
-			case "UseDelta":
-				if len(line.Values) > 0 {
-					deltaRatio, err := strconv.ParseFloat(line.Values[0], 64)
-
-					if err != nil {
-						break lineloop
-					}
-
-					conf.UseDelta = deltaRatio
-				}
-				continue lineloop
-			}
-
-			if currentSection != "options" {
-				err = fmt.Errorf("option %s outside of [options] section, at line %d",
-					line.Name, rdr.Lineno)
-				break lineloop
-			}
-			// main options.
-			if opt, ok := optionsMap[line.Name]; ok {
-				// boolean option.
-				conf.Options |= opt
-			} else {
-				// key-value option.
-				fld := confReflect.FieldByName(line.Name)
-				if !fld.IsValid() || !fld.CanAddr() {
-					_ = fmt.Errorf("unknown option at line %d: %s", rdr.Lineno, line.Name)
-					continue
-				}
-
-				switch fieldP := fld.Addr().Interface().(type) {
-				case *string:
-					// single valued option.
-					*fieldP = strings.Join(line.Values, " ")
-				case *[]string:
-					//many valued option.
-					*fieldP = append(*fieldP, line.Values...)
-				}
-			}
-		}
-	}
-
-	if len(conf.CleanMethod) == 0 {
-		conf.CleanMethod = []string{"KeepInstalled"}
-	}
-
-	if len(conf.CacheDir) == 0 {
-		conf.CacheDir = []string{"/var/cache/pacman/pkg/"} //should only be set if the config does not specify this
-	}
-
-	for n, _ := range conf.Repos {
-		repo := &conf.Repos[n]
-		if repo.Usage == 0 {
-			repo.Usage = UsageAll
-		}
-	}
-
-	return conf, err
-}
-
-func (conf *PacmanConfig) SetDefaults() {
-	conf.RootDir = "/"
-	conf.DBPath = "/var/lib/pacman"
-	conf.DBPath = "/var/lib/pacman/"
-	conf.HookDir = []string{"/etc/pacman.d/hooks/"} //should be added to whatever the config states
-	conf.GPGDir = "/etc/pacman.d/gnupg/"
-	conf.LogFile = "/var/log/pacman.log"
-	conf.UseDelta = 0.7
-
-	conf.SigLevel = SigPackage | SigPackageOptional | SigDatabase | SigDatabaseOptional
-	conf.LocalFileSigLevel = SigUseDefault
-	conf.RemoteFileSigLevel = SigUseDefault
-}
-
-func getArch() (string, error) {
-	var uname syscall.Utsname
-	err := syscall.Uname(&uname)
-	if err != nil {
-		return "", err
-	}
-	var arch [65]byte
-	for i, c := range uname.Machine {
-		if c == 0 {
-			return string(arch[:i]), nil
-		}
-		arch[i] = byte(c)
-	}
-	return string(arch[:]), nil
-}
-
-func (conf *PacmanConfig) CreateHandle() (*Handle, error) {
-	h, err := Init(conf.RootDir, conf.DBPath)
-	if err != nil {
-		return nil, err
-	}
-	if conf.Architecture == "auto" {
-		conf.Architecture, err = getArch()
-		if err != nil {
-			return nil, fmt.Errorf("architecture is 'auto' but couldn't uname()")
-		}
-	}
-
-	for _, repoconf := range conf.Repos {
-		// TODO: set SigLevel
-		db, err := h.RegisterSyncDb(repoconf.Name, 0)
-		if err == nil {
-			for i, addr := range repoconf.Servers {
-				addr = strings.Replace(addr, "$repo", repoconf.Name, -1)
-				addr = strings.Replace(addr, "$arch", conf.Architecture, -1)
-				repoconf.Servers[i] = addr
-			}
-			db.SetServers(repoconf.Servers)
-			db.SetUsage(repoconf.Usage)
-		}
-	}
-
-	err = h.SetCacheDirs(conf.CacheDir...)
-	if err != nil {
-		return nil, err
-	}
-
-	// add hook directories 1-by-1 to avoid overwriting the system directory
-	for _, dir := range conf.HookDir {
-		err = h.AddHookDir(dir)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	err = h.SetGPGDir(conf.GPGDir)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetLogFile(conf.LogFile)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetIgnorePkgs(conf.IgnorePkg...)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetIgnoreGroups(conf.IgnoreGroup...)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetArch(conf.Architecture)
-	if err != nil {
-		return nil, err
-	}
-
-	h.SetNoUpgrades(conf.NoUpgrade...)
-	if err != nil {
-		return nil, err
-	}
-
-	h.SetNoExtracts(conf.NoExtract...)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetDefaultSigLevel(conf.SigLevel)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetLocalFileSigLevel(conf.LocalFileSigLevel)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetRemoteFileSigLevel(conf.RemoteFileSigLevel)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetDeltaRatio(conf.UseDelta)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetUseSyslog(conf.Options&ConfUseSyslog > 0)
-	if err != nil {
-		return nil, err
-	}
-
-	err = h.SetCheckSpace(conf.Options&ConfCheckSpace > 0)
-	if err != nil {
-		return nil, err
-	}
-
-	return h, nil
-}

+ 53 - 51
vendor/github.com/jguer/go-alpm/handle.go

@@ -20,27 +20,29 @@ import (
 	"unsafe"
 )
 
+// Handle contains the pointer to the alpm handle
 type Handle struct {
 	ptr *C.alpm_handle_t
 }
 
-// Initialize
+// Init initializes alpm handle
 func Init(root, dbpath string) (*Handle, error) {
-	c_root := C.CString(root)
-	c_dbpath := C.CString(dbpath)
-	var c_err C.alpm_errno_t
-	h := C.alpm_initialize(c_root, c_dbpath, &c_err)
+	cRoot := C.CString(root)
+	cDBPath := C.CString(dbpath)
+	var cErr C.alpm_errno_t
+	h := C.alpm_initialize(cRoot, cDBPath, &cErr)
 
-	defer C.free(unsafe.Pointer(c_root))
-	defer C.free(unsafe.Pointer(c_dbpath))
+	defer C.free(unsafe.Pointer(cRoot))
+	defer C.free(unsafe.Pointer(cDBPath))
 
-	if c_err != 0 {
-		return nil, Error(c_err)
+	if cErr != 0 {
+		return nil, Error(cErr)
 	}
 
 	return &Handle{h}, nil
 }
 
+// Release releases the alpm handle
 func (h *Handle) Release() error {
 	if er := C.alpm_release(h.ptr); er != 0 {
 		return Error(er)
@@ -52,9 +54,9 @@ func (h *Handle) Release() error {
 // LastError gets the last pm_error
 func (h Handle) LastError() error {
 	if h.ptr != nil {
-		c_err := C.alpm_errno(h.ptr)
-		if c_err != 0 {
-			return Error(c_err)
+		cErr := C.alpm_errno(h.ptr)
+		if cErr != 0 {
+			return Error(cErr)
 		}
 	}
 	return nil
@@ -76,12 +78,12 @@ func (h Handle) optionGetList(f func(*C.alpm_handle_t) *C.alpm_list_t) (StringLi
 }
 
 func (h Handle) optionSetList(hookDirs []string, f func(*C.alpm_handle_t, *C.alpm_list_t) C.int) error {
-	var list *C.alpm_list_t = nil
+	var list *C.alpm_list_t
 
 	for _, dir := range hookDirs {
-		c_dir := C.CString(dir)
-		list = C.alpm_list_add(list, unsafe.Pointer(c_dir))
-		defer C.free(unsafe.Pointer(c_dir))
+		cDir := C.CString(dir)
+		list = C.alpm_list_add(list, unsafe.Pointer(cDir))
+		defer C.free(unsafe.Pointer(cDir))
 	}
 
 	ok := f(h.ptr, list)
@@ -92,9 +94,9 @@ func (h Handle) optionSetList(hookDirs []string, f func(*C.alpm_handle_t, *C.alp
 }
 
 func (h Handle) optionAddList(hookDir string, f func(*C.alpm_handle_t, *C.char) C.int) error {
-	c_hookdir := C.CString(hookDir)
-	defer C.free(unsafe.Pointer(c_hookdir))
-	ok := f(h.ptr, c_hookdir)
+	cHookDir := C.CString(hookDir)
+	defer C.free(unsafe.Pointer(cHookDir))
+	ok := f(h.ptr, cHookDir)
 	if ok < 0 {
 		return h.LastError()
 	}
@@ -102,9 +104,9 @@ func (h Handle) optionAddList(hookDir string, f func(*C.alpm_handle_t, *C.char)
 }
 
 func (h Handle) optionRemoveList(dir string, f func(*C.alpm_handle_t, *C.char) C.int) (bool, error) {
-	c_dir := C.CString(dir)
-	ok := f(h.ptr, c_dir)
-	defer C.free(unsafe.Pointer(c_dir))
+	cDir := C.CString(dir)
+	ok := f(h.ptr, cDir)
+	defer C.free(unsafe.Pointer(cDir))
 	if ok < 0 {
 		return ok == 1, h.LastError()
 	}
@@ -112,9 +114,9 @@ func (h Handle) optionRemoveList(dir string, f func(*C.alpm_handle_t, *C.char) C
 }
 
 func (h Handle) optionMatchList(dir string, f func(*C.alpm_handle_t, *C.char) C.int) (bool, error) {
-	c_dir := C.CString(dir)
-	ok := f(h.ptr, c_dir)
-	defer C.free(unsafe.Pointer(c_dir))
+	cDir := C.CString(dir)
+	ok := f(h.ptr, cDir)
+	defer C.free(unsafe.Pointer(cDir))
 	if ok == 0 {
 		return true, nil
 	} else if ok == C.FNM_NOMATCH {
@@ -125,9 +127,9 @@ func (h Handle) optionMatchList(dir string, f func(*C.alpm_handle_t, *C.char) C.
 
 //helper functions for *char based getters and setters
 func (h Handle) optionGetStr(f func(*C.alpm_handle_t) *C.char) (string, error) {
-	c_str := f(h.ptr)
-	str := C.GoString(c_str)
-	if c_str == nil {
+	cStr := f(h.ptr)
+	str := C.GoString(cStr)
+	if cStr == nil {
 		return str, h.LastError()
 	}
 
@@ -135,9 +137,9 @@ func (h Handle) optionGetStr(f func(*C.alpm_handle_t) *C.char) (string, error) {
 }
 
 func (h Handle) optionSetStr(str string, f func(*C.alpm_handle_t, *C.char) C.int) error {
-	c_str := C.CString(str)
-	defer C.free(unsafe.Pointer(c_str))
-	ok := f(h.ptr, c_str)
+	cStr := C.CString(str)
+	defer C.free(unsafe.Pointer(cStr))
+	ok := f(h.ptr, cStr)
 
 	if ok < 0 {
 		h.LastError()
@@ -253,12 +255,12 @@ func (h Handle) UseSyslog() (bool, error) {
 }
 
 func (h Handle) SetUseSyslog(value bool) error {
-	var int_value C.int = 0
+	var intValue C.int
 	if value {
-		int_value = 1
+		intValue = 1
 	}
 
-	ok := C.alpm_option_set_usesyslog(h.ptr, int_value)
+	ok := C.alpm_option_set_usesyslog(h.ptr, intValue)
 	if ok < 0 {
 		return h.LastError()
 	}
@@ -395,10 +397,10 @@ func (h Handle) AssumeInstalled() (DependList, error) {
 }
 
 func (h Handle) AddAssumeInstalled(dep Depend) error {
-	c_dep := convertCDepend(dep)
-	defer freeCDepend(c_dep)
+	cDep := convertCDepend(dep)
+	defer freeCDepend(cDep)
 
-	ok := C.alpm_option_add_assumeinstalled(h.ptr, c_dep)
+	ok := C.alpm_option_add_assumeinstalled(h.ptr, cDep)
 	if ok < 0 {
 		return h.LastError()
 	}
@@ -417,12 +419,12 @@ func (h Handle) SetAssumeInstalled(deps ...Depend) error {
 	//although for the sake of completeness it would be nice to have this
 	//working
 	panic("This function (SetAssumeInstalled) does not work properly, please do not use. See source code for more details")
-	var list *C.alpm_list_t = nil
+	var list *C.alpm_list_t
 
 	for _, dep := range deps {
-		c_dep := convertCDepend(dep)
-		defer freeCDepend(c_dep)
-		list = C.alpm_list_add(list, unsafe.Pointer(c_dep))
+		cDep := convertCDepend(dep)
+		defer freeCDepend(cDep)
+		list = C.alpm_list_add(list, unsafe.Pointer(cDep))
 	}
 
 	ok := C.alpm_option_set_assumeinstalled(h.ptr, list)
@@ -448,10 +450,10 @@ func (h Handle) RemoveAssumeInstalled(dep Depend) (bool, error) {
 	//although for the sake of completeness it would be nice to have this
 	//working
 	panic("This function (RemoveAssumeInstalled) does not work properly, please do not use. See source code for more details")
-	c_dep := convertCDepend(dep)
-	defer freeCDepend(c_dep)
+	cDep := convertCDepend(dep)
+	defer freeCDepend(cDep)
 
-	ok := C.alpm_option_remove_assumeinstalled(h.ptr, c_dep)
+	ok := C.alpm_option_remove_assumeinstalled(h.ptr, cDep)
 	if ok < 0 {
 		return ok == 1, h.LastError()
 	}
@@ -465,8 +467,8 @@ func (h Handle) Arch() (string, error) {
 }
 
 func (h Handle) SetArch(str string) error {
-	return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
-		return C.alpm_option_set_arch(handle, c_str)
+	return h.optionSetStr(str, func(handle *C.alpm_handle_t, cStr *C.char) C.int {
+		return C.alpm_option_set_arch(handle, cStr)
 	})
 }
 
@@ -500,12 +502,12 @@ func (h Handle) CheckSpace() (bool, error) {
 }
 
 func (h Handle) SetCheckSpace(value bool) error {
-	var int_value C.int = 0
+	var cValue C.int
 	if value {
-		int_value = 1
+		cValue = 1
 	}
 
-	ok := C.alpm_option_set_checkspace(h.ptr, int_value)
+	ok := C.alpm_option_set_checkspace(h.ptr, cValue)
 	if ok < 0 {
 		return h.LastError()
 	}
@@ -519,8 +521,8 @@ func (h Handle) DBExt() (string, error) {
 }
 
 func (h Handle) SetDBExt(str string) error {
-	return h.optionSetStr(str, func(handle *C.alpm_handle_t, c_str *C.char) C.int {
-		return C.alpm_option_set_dbext(handle, c_str)
+	return h.optionSetStr(str, func(handle *C.alpm_handle_t, cStr *C.char) C.int {
+		return C.alpm_option_set_dbext(handle, cStr)
 	})
 }
 

+ 4 - 4
vendor/github.com/jguer/go-alpm/package.go

@@ -272,8 +272,8 @@ func (pkg Package) ComputeRequiredBy() []string {
 	for i := (*list)(unsafe.Pointer(result)); i != nil; i = i.Next {
 		defer C.free(unsafe.Pointer(i))
 		if i.Data != nil {
-			defer C.free(unsafe.Pointer(i.Data))
-			name := C.GoString((*C.char)(unsafe.Pointer(i.Data)))
+			defer C.free(i.Data)
+			name := C.GoString((*C.char)(i.Data))
 			requiredby = append(requiredby, name)
 		}
 	}
@@ -287,8 +287,8 @@ func (pkg Package) ComputeOptionalFor() []string {
 	for i := (*list)(unsafe.Pointer(result)); i != nil; i = i.Next {
 		defer C.free(unsafe.Pointer(i))
 		if i.Data != nil {
-			defer C.free(unsafe.Pointer(i.Data))
-			name := C.GoString((*C.char)(unsafe.Pointer(i.Data)))
+			defer C.free(i.Data)
+			name := C.GoString((*C.char)(i.Data))
 			optionalfor = append(optionalfor, name)
 		}
 	}

+ 16 - 16
vendor/github.com/jguer/go-alpm/types.go

@@ -16,7 +16,7 @@ import (
 	"unsafe"
 )
 
-// Description of a dependency.
+// Depend provides a description of a dependency.
 type Depend struct {
 	Name        string
 	Version     string
@@ -36,19 +36,19 @@ func convertDepend(dep *C.alpm_depend_t) Depend {
 }
 
 func convertCDepend(dep Depend) *C.alpm_depend_t {
-	c_name := C.CString(dep.Name)
-	c_version := C.CString(dep.Version)
-	c_desc := C.CString(dep.Description)
-
-	c_dep := C.alpm_depend_t{
-		name:      c_name,
-		version:   c_version,
-		desc:      c_desc,
+	cName := C.CString(dep.Name)
+	cVersion := C.CString(dep.Version)
+	cDesc := C.CString(dep.Description)
+
+	cDep := C.alpm_depend_t{
+		name:      cName,
+		version:   cVersion,
+		desc:      cDesc,
 		name_hash: C.ulong(dep.NameHash),
 		mod:       C.alpm_depmod_t(dep.Mod),
 	}
 
-	return &c_dep
+	return &cDep
 }
 
 func freeCDepend(dep *C.alpm_depend_t) {
@@ -61,7 +61,7 @@ func (dep Depend) String() string {
 	return dep.Name + dep.Mod.String() + dep.Version
 }
 
-// Description of package files.
+// File provides a description of package files.
 type File struct {
 	Name string
 	Size int64
@@ -72,18 +72,18 @@ func convertFilelist(files *C.alpm_filelist_t) []File {
 	size := int(files.count)
 	items := make([]File, size)
 
-	raw_items := reflect.SliceHeader{
+	rawItems := reflect.SliceHeader{
 		Len:  size,
 		Cap:  size,
 		Data: uintptr(unsafe.Pointer(files.files))}
 
-	c_files := *(*[]C.alpm_file_t)(unsafe.Pointer(&raw_items))
+	cFiles := *(*[]C.alpm_file_t)(unsafe.Pointer(&rawItems))
 
 	for i := 0; i < size; i++ {
 		items[i] = File{
-			Name: C.GoString(c_files[i].name),
-			Size: int64(c_files[i].size),
-			Mode: uint32(c_files[i].mode)}
+			Name: C.GoString(cFiles[i].name),
+			Size: int64(cFiles[i].size),
+			Mode: uint32(cFiles[i].mode)}
 	}
 	return items
 }