Skip to content

Commit

Permalink
The behavior to follow symlink are default and no longer option
Browse files Browse the repository at this point in the history
  • Loading branch information
uudashr committed May 13, 2018
1 parent eee8944 commit c97a1ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ This are alternative to `go list all`, it just faster.
## Usage
```
$ gopkgs -help
Usage of gopkgs:
-follow-symlink
follow symbolic links
-format string
custom output format (default "{{.ImportPath}}")
-help
Expand Down
16 changes: 7 additions & 9 deletions cmd/gopkgs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Use -format to custom the output using template syntax. The struct being passed
Name string // package name
}
Use -workDir={path} to speed up the package search. This will ignore any vendor package outside the workDir.
Use -workDir={path} to speed up the package search. This will ignore any vendor package outside the package root.
`

func usage() {
Expand All @@ -36,11 +36,10 @@ func init() {

func main() {
var (
flagFormat = flag.String("format", "{{.ImportPath}}", "custom output format")
flagWorkDir = flag.String("workDir", "", "importable packages only for workDir")
flagNoVendor = flag.Bool("no-vendor", false, "exclude vendor dependencies except under workDir (if specified)")
flagFollowSymlink = flag.Bool("follow-symlink", false, "follow symbolic links")
flagHelp = flag.Bool("help", false, "show this message")
flagFormat = flag.String("format", "{{.ImportPath}}", "custom output format")
flagWorkDir = flag.String("workDir", "", "importable packages only for workDir")
flagNoVendor = flag.Bool("no-vendor", false, "exclude vendor dependencies except under workDir (if specified)")
flagHelp = flag.Bool("help", false, "show this message")
)

flag.Parse()
Expand All @@ -56,9 +55,8 @@ func main() {
}

pkgs, err := gopkgs.Packages(gopkgs.Options{
WorkDir: *flagWorkDir,
NoVendor: *flagNoVendor,
FollowSymlink: *flagFollowSymlink,
WorkDir: *flagWorkDir,
NoVendor: *flagNoVendor,
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down
7 changes: 3 additions & 4 deletions gopkgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ type Pkg struct {

// Options for retrieve packages.
type Options struct {
WorkDir string // Will return importable package under WorkDir. Any vendor dependencies outside the WorkDir will be ignored.
NoVendor bool // Will not retrieve vendor dependencies, except inside WorkDir (if specified)
FollowSymlink bool // Will follow symbolic links.
WorkDir string // Will return importable package under WorkDir. Any vendor dependencies outside the WorkDir will be ignored.
NoVendor bool // Will not retrieve vendor dependencies, except inside WorkDir (if specified)
}

type goFile struct {
Expand Down Expand Up @@ -83,7 +82,7 @@ func Packages(opts Options) (map[string]Pkg, error) {

for _, srcDir := range build.Default.SrcDirs() {
err := godirwalk.Walk(srcDir, &godirwalk.Options{
FollowSymbolicLinks: opts.FollowSymlink,
FollowSymbolicLinks: true,
Callback: func(osPathname string, de *godirwalk.Dirent) error {
// Ignore files begin with "_", "." "_test.go" and directory named "testdata"
// see: https://golang.org/cmd/go/#hdr-Description_of_package_lists
Expand Down

0 comments on commit c97a1ab

Please sign in to comment.