From d41fe52ef2dc52338f2d44a7b28a9cc94fcfd7fd Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 31 Oct 2019 11:12:18 -0400 Subject: [PATCH] a self-made mug is hard to break --- README.md | 3 --- azure-pipelines.yml | 15 +++------------ pkger.go | 10 ---------- pkger_test.go | 27 --------------------------- pkging/file.go | 3 --- pkging/mem/file.go | 5 ----- pkging/mem/mem.go | 14 -------------- pkging/pkger.go | 6 ------ pkging/stdos/file.go | 5 ----- pkging/wrap.go | 22 ---------------------- 10 files changed, 3 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 2773036..1040189 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,6 @@ Pkger's API is modeled on that of the [`os`](https://godoc.org/os) package in Go ```go type Pkger interface { Parse(p string) (Path, error) - Abs(p string) (string, error) - AbsPath(Path) (string, error) Current() (here.Info, error) Info(p string) (here.Info, error) Create(name string) (File, error) @@ -48,7 +46,6 @@ type Pkger interface { type File interface { Close() error - Abs() (string, error) Info() here.Info Name() string Open(name string) (http.File, error) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 108063a..5fe60c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,11 +10,8 @@ jobs: vmImage: "vs2017-win2016" strategy: matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" go 1.13 (on): - go_version: "1.13" + go_version: "1.13.3" GO111MODULE: "on" steps: - template: azure-tests.yml @@ -24,11 +21,8 @@ jobs: vmImage: "macOS-10.13" strategy: matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" go 1.13 (on): - go_version: "1.13" + go_version: "1.13.3" GO111MODULE: "on" steps: - template: azure-tests.yml @@ -38,11 +32,8 @@ jobs: vmImage: "ubuntu-16.04" strategy: matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" go 1.13 (on): - go_version: "1.13" + go_version: "1.13.3" GO111MODULE: "on" steps: - template: azure-tests.yml diff --git a/pkger.go b/pkger.go index 6bcbd27..67cefb5 100644 --- a/pkger.go +++ b/pkger.go @@ -51,16 +51,6 @@ func Parse(p string) (here.Path, error) { return impl().Parse(p) } -// Abs returns an absolute representation of path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. -func Abs(p string) (string, error) { - return impl().Abs(p) -} - -// AbsPath returns an absolute representation of here.Path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. AbsPath calls Clean on the result. -func AbsPath(p here.Path) (string, error) { - return impl().AbsPath(p) -} - // Current returns the here.Info representing the current Pkger implementation. func Current() (here.Info, error) { return impl().Current() diff --git a/pkger_test.go b/pkger_test.go index d038a29..bf1addf 100644 --- a/pkger_test.go +++ b/pkger_test.go @@ -2,10 +2,8 @@ package pkger import ( "os" - "path/filepath" "testing" - "github.com/markbates/pkger/here" "github.com/stretchr/testify/require" ) @@ -18,31 +16,6 @@ func Test_Parse(t *testing.T) { r.Equal("/little", pt.Name) } -func Test_Abs(t *testing.T) { - r := require.New(t) - - s, err := Abs(":/rocket.ship") - r.NoError(err) - - pwd, err := os.Getwd() - r.NoError(err) - r.Equal(filepath.Join(pwd, "rocket.ship"), s) -} - -func Test_AbsPath(t *testing.T) { - r := require.New(t) - - s, err := AbsPath(here.Path{ - Pkg: "github.com/markbates/pkger", - Name: "/rocket.ship", - }) - r.NoError(err) - - pwd, err := os.Getwd() - r.NoError(err) - r.Equal(filepath.Join(pwd, "rocket.ship"), s) -} - func Test_Current(t *testing.T) { r := require.New(t) diff --git a/pkging/file.go b/pkging/file.go index a09372e..c7d12a1 100644 --- a/pkging/file.go +++ b/pkging/file.go @@ -11,9 +11,6 @@ type File interface { // Close closes the File, rendering it unusable for I/O. Close() error - // Abs returns an absolute representation of the file. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. - Abs() (string, error) - // Info returns the here.Info of the file Info() here.Info diff --git a/pkging/mem/file.go b/pkging/mem/file.go index 6167d77..fd21e6e 100644 --- a/pkging/mem/file.go +++ b/pkging/mem/file.go @@ -104,11 +104,6 @@ func (f File) Name() string { return f.path.String() } -// Abs returns an absolute representation of the file. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. -func (f File) Abs() (string, error) { - return f.pkging.AbsPath(f.Path()) -} - // Path returns the here.Path of the file func (f File) Path() here.Path { return f.path diff --git a/pkging/mem/mem.go b/pkging/mem/mem.go index 6345cb9..1590e3e 100644 --- a/pkging/mem/mem.go +++ b/pkging/mem/mem.go @@ -32,20 +32,6 @@ type Pkger struct { files *maps.Files } -// Abs returns an absolute representation of path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. -func (f *Pkger) Abs(p string) (string, error) { - pt, err := f.Parse(p) - if err != nil { - return "", err - } - return f.AbsPath(pt) -} - -// AbsPath returns an absolute representation of here.Path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. AbsPath calls Clean on the result. -func (f *Pkger) AbsPath(pt here.Path) (string, error) { - return pt.String(), nil -} - // Current returns the here.Info representing the current Pkger implementation. func (f *Pkger) Current() (here.Info, error) { return f.Here, nil diff --git a/pkging/pkger.go b/pkging/pkger.go index 2a3d996..0022db2 100644 --- a/pkging/pkger.go +++ b/pkging/pkger.go @@ -11,12 +11,6 @@ type Pkger interface { // Parse the string in here.Path format. Parse(p string) (here.Path, error) - // Abs returns an absolute representation of path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. - Abs(p string) (string, error) - - // AbsPath returns an absolute representation of here.Path. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. AbsPath calls Clean on the result. - AbsPath(here.Path) (string, error) - // Current returns the here.Info representing the current Pkger implementation. Current() (here.Info, error) diff --git a/pkging/stdos/file.go b/pkging/stdos/file.go index 173448a..35845cf 100644 --- a/pkging/stdos/file.go +++ b/pkging/stdos/file.go @@ -24,11 +24,6 @@ func (f *File) Close() error { return f.File.Close() } -// Abs returns an absolute representation of the file. If the path is not absolute it will be joined with the current working directory to turn it into an absolute path. The absolute path name for a given file is not guaranteed to be unique. Abs calls Clean on the result. -func (f *File) Abs() (string, error) { - return f.pkging.AbsPath(f.path) -} - // Info returns the here.Info of the file func (f *File) Info() here.Info { return f.her diff --git a/pkging/wrap.go b/pkging/wrap.go index 5ae8ca1..438f955 100644 --- a/pkging/wrap.go +++ b/pkging/wrap.go @@ -38,28 +38,6 @@ func (w withPkger) Parse(p string) (here.Path, error) { return pt, nil } -func (w withPkger) Abs(p string) (string, error) { - pt, err := w.base.Abs(p) - if err != nil { - if w.parent != nil { - return w.parent.Abs(p) - } - return pt, err - } - return pt, nil -} - -func (w withPkger) AbsPath(p here.Path) (string, error) { - pt, err := w.base.AbsPath(p) - if err != nil { - if w.parent != nil { - return w.parent.AbsPath(p) - } - return pt, err - } - return pt, nil -} - func (w withPkger) Current() (here.Info, error) { pt, err := w.base.Current() if err != nil {