aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-02-01 00:23:55 +0700
committerShulhan <ms@kilabit.info>2022-02-01 00:24:20 +0700
commitb49ef8b92d182759a5b9312428bea3d5095ddeaf (patch)
tree3f4bcb1134c2d5c27c04ce0208000ea0d816b336
parenta8e38e2232a1b763fb27c707826c16a89af4772f (diff)
downloadbeku-b49ef8b92d182759a5b9312428bea3d5095ddeaf.tar.xz
all: remove the flag vendor
Since vendoring is already handled by Go module, we remove this feature to minimize duplication.
-rw-r--r--README.md10
-rw-r--r--beku.go1
-rw-r--r--beku_test.go2
-rw-r--r--cmd/beku/command.go17
-rw-r--r--cmd/beku/main.go2
-rw-r--r--env.go100
-rw-r--r--package.go4
-rw-r--r--package_test.go3
-rw-r--r--testdata/beku.db1
9 files changed, 40 insertions, 100 deletions
diff --git a/README.md b/README.md
index 4b593ac..c719057 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Beku
Beku is a library and program to manage packages in user's environment (GOPATH
-or vendor directory).
+directory).
For beku as library see the following
[![GoDoc](https://godoc.org/github.com/shuLhan/beku?status.svg)](https://godoc.org/github.com/shuLhan/beku).
@@ -12,7 +12,7 @@ For beku as program see the below documentation or at
## Beku program
Beku is command line program to manage packages in user's environment (GOPATH
-or vendor directory). Beku provide syntax like `pacman`.
+directory). Beku provide syntax like `pacman`.
Beku read and write the package database into a file named "beku.db".
@@ -34,12 +34,6 @@ inside a script.
Do not install any missing dependencies. This options can be used on freeze
or sync operations.
- -V, --vendor
-
-Operate in vendor mode. This option used only when first scanning
-(`beku -V -S`).
-Any operation after that, will use the "vendor" directory in current
-working directory as installation prefix.
## Freeze Operation
diff --git a/beku.go b/beku.go
index f3acc61..bf2524c 100644
--- a/beku.go
+++ b/beku.go
@@ -44,7 +44,6 @@ const (
sectionPackage = "package"
keyExclude = "exclude"
- keyVendor = "vendor"
keyDeps = "deps"
keyDepsMissing = "missing"
diff --git a/beku_test.go b/beku_test.go
index 209f630..e972b64 100644
--- a/beku_test.go
+++ b/beku_test.go
@@ -49,7 +49,7 @@ func TestMain(m *testing.M) {
defStdout = mock.Stdout()
defStderr = mock.Stderr()
- testEnv, err = NewEnvironment(false, false)
+ testEnv, err = NewEnvironment(false)
if err != nil {
log.Fatal(err)
}
diff --git a/cmd/beku/command.go b/cmd/beku/command.go
index 00e292c..d82eb24 100644
--- a/cmd/beku/command.go
+++ b/cmd/beku/command.go
@@ -36,7 +36,6 @@ const (
flagOptionRecursive = "Remove package including their dependencies."
flagOptionSyncInto = "Download package into `directory`."
flagOptionUpdate = "Update all packages to latest version."
- flagOptionVendor = "Operate in vendor mode."
)
type command struct {
@@ -47,7 +46,6 @@ type command struct {
firstTime bool
noConfirm bool
noDeps bool
- vendor bool
}
func (cmd *command) usage() {
@@ -57,8 +55,6 @@ common options:
` + flagOptionNoConfirm + `
-d,--nodeps
` + flagOptionNoDeps + `
- -V,--vendor
- ` + flagOptionVendor + `
operations:
beku {-h|--help}
` + flagOperationHelp + `
@@ -220,11 +216,6 @@ func (cmd *command) parseShortFlags(arg string) (operation, error) {
return opNone, err
}
op |= opRemove
- case 'V':
- if len(arg) > 1 {
- return opNone, errInvalidOptions
- }
- cmd.vendor = true
default:
return opNone, errInvalidOptions
}
@@ -263,8 +254,6 @@ func (cmd *command) parseLongFlags(arg string) (op operation, err error) {
op = opSync
case "update":
op = opUpdate
- case "vendor":
- cmd.vendor = true
case "version":
op = opVersion
default:
@@ -359,10 +348,6 @@ func (cmd *command) loadDatabase() (err error) {
return
}
- if !cmd.vendor {
- err = cmd.env.Load("")
- }
-
return
}
@@ -415,7 +400,7 @@ func newCommand() (cmd *command, err error) {
os.Exit(0)
}
- cmd.env, err = beku.NewEnvironment(cmd.vendor, cmd.noDeps)
+ cmd.env, err = beku.NewEnvironment(cmd.noDeps)
if err != nil {
return
}
diff --git a/cmd/beku/main.go b/cmd/beku/main.go
index f170e37..72ca3a8 100644
--- a/cmd/beku/main.go
+++ b/cmd/beku/main.go
@@ -4,7 +4,7 @@
//
// Beku is a command line program to manage packages in user's environment
-// (GOPATH or vendor) directory. Beku provide syntax like `pacman`.
+// (GOPATH) directory. Beku provide syntax like `pacman`.
//
// See README in root of this repository for user manual [1].
//
diff --git a/env.go b/env.go
index c9776a6..57f9097 100644
--- a/env.go
+++ b/env.go
@@ -4,7 +4,7 @@
//
// Package beku provide library for managing Go packages in user's environment
-// (GOPATH or vendor directory).
+// (GOPATH directory).
//
package beku
@@ -28,63 +28,60 @@ import (
// packages, and list of missing packages.
//
type Env struct {
- path string
- prefix string
+ path string
+ prefix string // Equal to GOPATH.
+
dirBin string
- dirPkg string
dirGoRootSrc string
+ dirPkg string
dirSrc string
- pkgs []*Package
- pkgsExclude []string
- pkgsMissing []string
- pkgsStd []string
- pkgsUnused []*Package
- db *ini.Ini
- dbDefFile string
- dbFile string
- countNew int
- countUpdate int
- fmtMaxPath int
- dirty bool
- NoConfirm bool
- noDeps bool
- vendor bool
+
+ dbDefFile string
+ dbFile string
+
+ pkgs []*Package
+ pkgsExclude []string
+ pkgsMissing []string
+ pkgsStd []string
+ pkgsUnused []*Package
+
+ db *ini.Ini
+
+ countNew int
+ countUpdate int
+ fmtMaxPath int
+
+ dirty bool
+ NoConfirm bool
+ noDeps bool
}
//
// NewEnvironment will gather all information in user system.
//
-func NewEnvironment(vendor, noDeps bool) (env *Env, err error) {
- if !vendor && len(build.Default.GOPATH) == 0 {
- vendor = true
- }
+func NewEnvironment(noDeps bool) (env *Env, err error) {
if len(build.Default.GOROOT) == 0 {
return nil, ErrGOROOT
}
env = &Env{
- path: os.Getenv(envPATH),
- dirGoRootSrc: filepath.Join(build.Default.GOROOT, dirSrc),
+ path: os.Getenv(envPATH),
+ prefix: build.Default.GOPATH,
+
dirBin: filepath.Join(build.Default.GOPATH, dirBin),
- dirPkg: filepath.Join(build.Default.GOPATH, dirPkg,
- build.Default.GOOS+"_"+build.Default.GOARCH),
+ dirGoRootSrc: filepath.Join(build.Default.GOROOT, dirSrc),
+ dirPkg: filepath.Join(build.Default.GOPATH, dirPkg, build.Default.GOOS+"_"+build.Default.GOARCH),
+ dirSrc: filepath.Join(build.Default.GOPATH, dirSrc),
+
+ dbDefFile: filepath.Join(build.Default.GOPATH, dirDB, DefDBName),
+
noDeps: noDeps,
- vendor: vendor,
}
if len(env.path) == 0 {
env.path = defPATH
}
- if vendor {
- err = env.initVendor()
- if err != nil {
- return
- }
- } else {
- env.initGopath()
- }
-
err = env.scanStdPackages(env.dirGoRootSrc)
if err != nil {
return nil, err
@@ -94,24 +91,6 @@ func NewEnvironment(vendor, noDeps bool) (env *Env, err error) {
}
func (env *Env) initGopath() {
- env.prefix = build.Default.GOPATH
- env.dirSrc = filepath.Join(build.Default.GOPATH, dirSrc)
- env.dbDefFile = filepath.Join(build.Default.GOPATH, dirDB, DefDBName)
-}
-
-func (env *Env) initVendor() (err error) {
- wd, err := os.Getwd()
- if err != nil {
- return
- }
-
- prefix := strings.TrimPrefix(wd, filepath.Join(build.Default.GOPATH, dirSrc)+"/")
-
- env.prefix = filepath.Join(prefix, dirVendor)
- env.dirSrc = filepath.Join(wd, dirVendor)
- env.dbDefFile = DefDBName
-
- return
}
//
@@ -557,8 +536,6 @@ func (env *Env) Load(file string) (err error) {
}
func (env *Env) loadBeku() {
- env.vendor = env.db.GetBool(sectionBeku, "", keyVendor, false)
-
for _, v := range env.db.Gets(sectionBeku, "", keyExclude) {
env.addExclude(v)
}
@@ -903,12 +880,6 @@ func (env *Env) Save(file string) (err error) {
}
func (env *Env) saveBeku() {
- if env.vendor {
- env.db.Set(sectionBeku, "", keyVendor, "true")
- } else {
- env.db.Set(sectionBeku, "", keyVendor, "false")
- }
-
for _, exclude := range env.pkgsExclude {
env.db.Add(sectionBeku, "", keyExclude, exclude)
}
@@ -944,14 +915,13 @@ func (env *Env) String() string {
fmt.Fprintf(&buf, `
[ENV]
- Vendor: %t
Prefix: %s
Dir bin: %s
Dir pkg: %s
Dir src: %s
Dir root src: %s
Standard Packages: %s
-`, env.vendor, env.prefix, env.dirBin, env.dirPkg, env.dirSrc, env.dirGoRootSrc, env.pkgsStd)
+`, env.prefix, env.dirBin, env.dirPkg, env.dirSrc, env.dirGoRootSrc, env.pkgsStd)
for x := 0; x < len(env.pkgs); x++ {
fmt.Fprintf(&buf, "%s", env.pkgs[x].String())
diff --git a/package.go b/package.go
index 2bd5467..2249a39 100644
--- a/package.go
+++ b/package.go
@@ -325,10 +325,6 @@ func (pkg *Package) GetRecursiveImports(env *Env) (
importsDup := strings.Split(string(out), "\n")
for x := 0; x < len(importsDup); x++ {
- if env.vendor {
- importsDup[x] = strings.TrimPrefix(importsDup[x], env.prefix+"/")
- }
-
found = false
for y := 0; y < len(imports); y++ {
if importsDup[x] == imports[y] {
diff --git a/package_test.go b/package_test.go
index 04c8d02..4bebe24 100644
--- a/package_test.go
+++ b/package_test.go
@@ -191,9 +191,6 @@ func TestAddDep(t *testing.T) {
desc: "Is the same path as package",
importPath: testGitRepo,
}, {
- desc: "Is vendor package",
- importPath: "vendor/github.com/shuLhan/beku",
- }, {
desc: "Is standard package",
importPath: "os/exec",
}, {
diff --git a/testdata/beku.db b/testdata/beku.db
index 691f238..9777326 100644
--- a/testdata/beku.db
+++ b/testdata/beku.db
@@ -1,5 +1,4 @@
[beku]
-vendor = false
[package "github.com/alecthomas/gometalinter"]
vcs = git