-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from nezorflame/module-v2
Add new `v2` module and make `cmd/gopkgs` use it
- Loading branch information
Showing
11 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/uudashr/gopkgs/cmd/gopkgs | ||
|
||
go 1.13 | ||
|
||
require github.com/uudashr/gopkgs/v2 v2.0.3 | ||
|
||
replace ( | ||
github.com/uudashr/gopkgs => ../../ | ||
github.com/uudashr/gopkgs/v2 => ../../v2 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/karrick/godirwalk v1.12.0 h1:nkS4xxsjiZMvVlazd0mFyiwD4BR9f3m6LXGhM2TUx3Y= | ||
github.com/karrick/godirwalk v1.12.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= | ||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module github.com/uudashr/gopkgs/v2 | ||
|
||
go 1.13 | ||
|
||
require github.com/uudashr/gopkgs v0.0.0 | ||
|
||
replace github.com/uudashr/gopkgs => ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/karrick/godirwalk v1.12.0 h1:nkS4xxsjiZMvVlazd0mFyiwD4BR9f3m6LXGhM2TUx3Y= | ||
github.com/karrick/godirwalk v1.12.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= | ||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package gopkgs | ||
|
||
import ( | ||
v1 "github.com/uudashr/gopkgs" | ||
) | ||
|
||
// Pkg hold the information of the package. | ||
type Pkg v1.Pkg | ||
|
||
// Options for retrieve packages. | ||
type Options v1.Options | ||
|
||
// List packages on workDir. | ||
func List(opts Options) (map[string]Pkg, error) { | ||
result, err := v1.List(v1.Options(opts)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pkgs := make(map[string]Pkg, len(result)) | ||
for key, pkg := range result { | ||
pkgs[key] = Pkg(pkg) | ||
} | ||
return pkgs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package gopkgs_test | ||
|
||
import ( | ||
"testing" | ||
|
||
gopkgs "github.com/uudashr/gopkgs/v2" | ||
) | ||
|
||
func TestList(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("Skip non-short mode") | ||
} | ||
|
||
pkgs, err := gopkgs.List(gopkgs.Options{}) | ||
if err != nil { | ||
t.Fatal("fail getting packages:", err) | ||
} | ||
|
||
if got := len(pkgs); got == 0 { | ||
t.Error("got:", got, "want: greater than 0") | ||
} | ||
} | ||
|
||
func BenchmarkList(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
if _, err := gopkgs.List(gopkgs.Options{}); err != nil { | ||
b.Fatal("err:", err) | ||
} | ||
} | ||
} |