diff --git a/.gitignore b/.gitignore index c83d876..d67e8e8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,3 @@ # Other folders and files vendor/ dist/ -go.sum diff --git a/.goreleaser.yml b/.goreleaser.yml index 96d1ef4..77a3148 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,13 +18,12 @@ builds: - "386" - arm - arm64 - goarm: - - "6" main: ./cli/mklink/ ldflags: -s -w -X github.com/spiegel-im-spiegel/mklink/cli/mklink/facade.Version=v{{ .Version }} binary: mklink -archive: +archives: +- format: tar.gz format_overrides: - goos: windows diff --git a/.travis.yml b/.travis.yml index e36ea9c..f59f71d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: -- "1.12.x" +- "1.13.x" env: global: diff --git a/README.md b/README.md index 51bc95c..3490b59 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ See [go.mod](https://github.com/spiegel-im-spiegel/mklink/blob/master/go.mod) file. -![mklink](./mklink.png) - ## Usage ```go diff --git a/cli/mklink/facade/facade_test.go b/cli/mklink/facade/facade_test.go index 633c548..969a1af 100644 --- a/cli/mklink/facade/facade_test.go +++ b/cli/mklink/facade/facade_test.go @@ -26,7 +26,7 @@ func TestStyleMarkdown(t *testing.T) { outBuf := new(bytes.Buffer) outErrBuf := new(bytes.Buffer) ui := rwi.New(rwi.WithWriter(outBuf), rwi.WithErrorWriter(outErrBuf)) - args := []string{"http://text.baldanders.info"} + args := []string{"https://text.baldanders.info"} exit := Execute(ui, args) if exit != exitcode.Normal { @@ -37,7 +37,7 @@ func TestStyleMarkdown(t *testing.T) { t.Errorf("Execute(markdown) = \"%v\", want \"%v\".", str, "") } str = outBuf.String() - res := "[text.Baldanders.info](http://text.baldanders.info)\n" + res := "[text.Baldanders.info](https://text.baldanders.info)\n" if str != res { t.Errorf("Execute(markdown) = \"%v\", want \"%v\".", str, res) } @@ -59,7 +59,7 @@ func TestStyleWiki(t *testing.T) { outBuf := new(bytes.Buffer) outErrBuf := new(bytes.Buffer) ui := rwi.New(rwi.WithWriter(outBuf), rwi.WithErrorWriter(outErrBuf)) - args := []string{"-s", "wiki", "http://text.baldanders.info"} + args := []string{"-s", "wiki", "https://text.baldanders.info"} exit := Execute(ui, args) if exit != exitcode.Normal { @@ -70,14 +70,14 @@ func TestStyleWiki(t *testing.T) { t.Errorf("Execute(wiki) = \"%v\", want \"%v\".", str, "") } str = outBuf.String() - res := "[http://text.baldanders.info text.Baldanders.info]\n" + res := "[https://text.baldanders.info text.Baldanders.info]\n" if str != res { t.Errorf("Execute(wiki) = \"%v\", want \"%v\".", str, res) } } func TestPipe(t *testing.T) { - inData := bytes.NewBufferString("http://text.baldanders.info") + inData := bytes.NewBufferString("https://text.baldanders.info") outBuf := new(bytes.Buffer) outErrBuf := new(bytes.Buffer) ui := rwi.New(rwi.WithReader(inData), rwi.WithWriter(outBuf), rwi.WithErrorWriter(outErrBuf)) @@ -92,7 +92,7 @@ func TestPipe(t *testing.T) { t.Errorf("Execute(pipe) = \"%v\", want \"%v\".", str, "") } str = outBuf.String() - res := "[text.Baldanders.info](http://text.baldanders.info)\n" + res := "[text.Baldanders.info](https://text.baldanders.info)\n" if str != res { t.Errorf("Execute(pipe) = \"%v\", want \"%v\".", str, res) } diff --git a/cli/mklink/facade/interactive.go b/cli/mklink/facade/interactive.go index 72369fc..97dfef6 100644 --- a/cli/mklink/facade/interactive.go +++ b/cli/mklink/facade/interactive.go @@ -5,10 +5,10 @@ import ( "io" "github.com/atotto/clipboard" + "github.com/spiegel-im-spiegel/errs" "github.com/spiegel-im-spiegel/gocli/rwi" "github.com/spiegel-im-spiegel/gprompt" "github.com/spiegel-im-spiegel/mklink/cli/mklink/makelink" - "github.com/spiegel-im-spiegel/mklink/errs" ) func interactiveMode(ui *rwi.RWI, cxt *makelink.Context) error { diff --git a/cli/mklink/makelink/makelink.go b/cli/mklink/makelink/makelink.go index d21227e..6cca888 100644 --- a/cli/mklink/makelink/makelink.go +++ b/cli/mklink/makelink/makelink.go @@ -5,8 +5,8 @@ import ( "fmt" "io" + "github.com/spiegel-im-spiegel/errs" "github.com/spiegel-im-spiegel/mklink" - "github.com/spiegel-im-spiegel/mklink/errs" ) //Context class is context for making link @@ -23,7 +23,7 @@ func New(s mklink.Style, log io.Writer) *Context { //MakeLink is making link func (c *Context) MakeLink(url string) (io.Reader, error) { if c == nil { - return nil, errs.Wrap(errs.ErrNullPointer, "reference error") + return nil, errs.Wrap(mklink.ErrNullPointer, "reference error") } lnk, err := mklink.New(url) if err != nil { diff --git a/errs/errs.go b/errs.go similarity index 98% rename from errs/errs.go rename to errs.go index 88c148f..09791bf 100644 --- a/errs/errs.go +++ b/errs.go @@ -1,4 +1,4 @@ -package errs +package mklink import "fmt" diff --git a/errs/cause.go b/errs/cause.go deleted file mode 100644 index 9809682..0000000 --- a/errs/cause.go +++ /dev/null @@ -1,30 +0,0 @@ -package errs - -import ( - errors "golang.org/x/xerrors" -) - -func Cause(err error) error { - for { - unwrap := errors.Unwrap(err) - if unwrap == nil { - return err - } - err = unwrap - } -} - -/* Copyright 2019 Spiegel -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ diff --git a/errs/errs_test.go b/errs/errs_test.go deleted file mode 100644 index 436eed2..0000000 --- a/errs/errs_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package errs - -import ( - "fmt" - "testing" - - errors "golang.org/x/xerrors" -) - -func TestNumError(t *testing.T) { - testCases := []struct { - err error - str string - }{ - {err: Num(0), str: "unknown error (0)"}, - {err: ErrNoImplement, str: "This style is not implementation"}, - {err: ErrNullPointer, str: "Null reference instance"}, - {err: Num(3), str: "unknown error (3)"}, - } - - for _, tc := range testCases { - errStr := tc.err.Error() - if errStr != tc.str { - t.Errorf("\"%v\" != \"%v\"", errStr, tc.str) - } - fmt.Printf("Info(TestNumError): %+v\n", tc.err) - } -} - -func TestNumErrorEquality(t *testing.T) { - testCases := []struct { - err1 error - err2 error - res bool - }{ - {err1: ErrNullPointer, err2: ErrNullPointer, res: true}, - {err1: ErrNoImplement, err2: ErrNoImplement, res: true}, - {err1: ErrNullPointer, err2: Wrap(ErrNullPointer, "wrapping error"), res: false}, - {err1: ErrNoImplement, err2: Wrap(ErrNoImplement, "wrapping error"), res: false}, - {err1: ErrNullPointer, err2: nil, res: false}, - {err1: ErrNullPointer, err2: Num(0), res: false}, - } - - for _, tc := range testCases { - res := errors.Is(tc.err1, tc.err2) - if res != tc.res { - t.Errorf("\"%v\" == \"%v\" ? %v, want %v", tc.err1, tc.err2, res, tc.res) - } - } -} - -func TestWrapError(t *testing.T) { - testCases := []struct { - err error - msg string - str string - }{ - {err: ErrNullPointer, msg: "wrapping error", str: "wrapping error: Null reference instance"}, - {err: ErrNoImplement, msg: "wrapping error", str: "wrapping error: This style is not implementation"}, - } - - for _, tc := range testCases { - we := Wrap(tc.err, tc.msg) - if we.Error() != tc.str { - t.Errorf("wrapError.Error() == \"%v\", want \"%v\"", we.Error(), tc.str) - } - fmt.Printf("Info(TestWrapError): %+v\n", we) - } -} - -func TestWrapNilError(t *testing.T) { - if we := Wrap(nil, "null error"); we != nil { - t.Errorf("Wrap(nil) == \"%v\", want nil.", we) - } -} - -func TestWrapfError(t *testing.T) { - testCases := []struct { - err error - msg string - str string - }{ - {err: ErrNoImplement, msg: "wrapping error", str: "wrapping error: This style is not implementation"}, - {err: ErrNullPointer, msg: "wrapping error", str: "wrapping error: Null reference instance"}, - } - - for _, tc := range testCases { - we := Wrapf(tc.err, "%v", tc.msg) - if we.Error() != tc.str { - t.Errorf("wrapError.Error() == \"%v\", want \"%v\"", we.Error(), tc.str) - } - fmt.Printf("Info(TestWrapfError): %+v\n", we) - } -} - -func TestWrapfNilError(t *testing.T) { - if we := Wrapf(nil, "%v", "null error"); we != nil { - t.Errorf("Wrapf(nil) == \"%v\", want nil.", we) - } -} - -func TestWrapErrorEquality(t *testing.T) { - testCases := []struct { - err1 error - err2 error - res bool - }{ - {err1: Wrap(ErrNoImplement, "wrapping error"), err2: ErrNoImplement, res: true}, - {err1: Wrap(ErrNullPointer, "wrapping error"), err2: ErrNullPointer, res: true}, - {err1: Wrap(ErrNoImplement, "wrapping error"), err2: nil, res: false}, - {err1: Wrap(ErrNoImplement, "wrapping error"), err2: Num(0), res: false}, - {err1: Wrap(ErrNoImplement, "wrapping error"), err2: Wrap(Num(0), "wrapping error"), res: false}, - } - - for _, tc := range testCases { - res := errors.Is(tc.err1, tc.err2) - if res != tc.res { - t.Errorf("\"%v\" == \"%v\" ? %v, want %v", tc.err1, tc.err2, res, tc.res) - } - } -} - -/* Copyright 2019 Spiegel -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ diff --git a/errs/wrapper.go b/errs/wrapper.go deleted file mode 100644 index 14af44b..0000000 --- a/errs/wrapper.go +++ /dev/null @@ -1,67 +0,0 @@ -package errs - -import ( - "fmt" - - errors "golang.org/x/xerrors" -) - -//wrapError is wrapper for error instance -type wrapError struct { - msg string - cause error - frame errors.Frame -} - -//Wrap returns wraped error instance -func Wrap(err error, msg string) error { - if err == nil { - return nil - } - return &wrapError{msg: msg, cause: err, frame: errors.Caller(1)} -} - -//Wrapf returns wraped error instance -func Wrapf(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - return &wrapError{msg: fmt.Sprintf(format, args...), cause: err, frame: errors.Caller(1)} -} - -//Error method for error interface -func (we *wrapError) Error() string { - return fmt.Sprintf("%v: %v", we.msg, we.cause) -} - -//Unwrap method for errors.Wrapper interface -func (e *wrapError) Unwrap() error { - return e.cause -} - -//Format method for fmt.Formatter interface -func (we *wrapError) Format(s fmt.State, v rune) { - errors.FormatError(we, s, v) -} - -//FormatError method for errors.Formatter interface -func (we *wrapError) FormatError(p errors.Printer) error { - p.Print(we.msg) - we.frame.Format(p) - return we.cause -} - -/* Copyright 2019 Spiegel -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. - */ diff --git a/errs/cause_test.go b/errs_test.go similarity index 60% rename from errs/cause_test.go rename to errs_test.go index 6008da8..05ff1ec 100644 --- a/errs/cause_test.go +++ b/errs_test.go @@ -1,24 +1,27 @@ -package errs +package mklink import ( + "fmt" "testing" ) -func TestCause(t *testing.T) { +func TestNumError(t *testing.T) { testCases := []struct { - err error - cause error + err error + str string }{ - {err: nil, cause: nil}, - {err: ErrNoImplement, cause: ErrNoImplement}, - {err: Wrap(ErrNoImplement, "wrapping error"), cause: ErrNoImplement}, + {err: Num(0), str: "unknown error (0)"}, + {err: ErrNoImplement, str: "This style is not implementation"}, + {err: ErrNullPointer, str: "Null reference instance"}, + {err: Num(3), str: "unknown error (3)"}, } for _, tc := range testCases { - res := Cause(tc.err) - if res != tc.cause { - t.Errorf("Cause in \"%v\" == \"%v\", want \"%v\"", tc.err, res, tc.cause) + errStr := tc.err.Error() + if errStr != tc.str { + t.Errorf("\"%v\" != \"%v\"", errStr, tc.str) } + fmt.Printf("Info(TestNumError): %+v\n", tc.err) } } diff --git a/go.mod b/go.mod index 3d184d7..a508448 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,14 @@ module github.com/spiegel-im-spiegel/mklink -go 1.12 +go 1.13 require ( github.com/PuerkitoBio/goquery v1.5.0 github.com/atotto/clipboard v0.1.2 github.com/mattn/go-encoding v0.0.2 - github.com/spf13/cobra v0.0.3 - github.com/spf13/pflag v1.0.3 // indirect - github.com/spiegel-im-spiegel/gocli v0.9.5 - github.com/spiegel-im-spiegel/gprompt v0.9.5 - golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c - golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373 + github.com/spf13/cobra v0.0.5 + github.com/spiegel-im-spiegel/errs v0.3.2 + github.com/spiegel-im-spiegel/gocli v0.10.1 + github.com/spiegel-im-spiegel/gprompt v0.9.6 + golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 ) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1b06844 --- /dev/null +++ b/go.sum @@ -0,0 +1,57 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk= +github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= +github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o= +github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY= +github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-encoding v0.0.2 h1:OC1L+QXLJge9n7yIE3R5Os/UNasUeFvK3Sa4NjbDi6c= +github.com/mattn/go-encoding v0.0.2/go.mod h1:WUNsdPQLK4JYRzkn8IAdmYKFYGGJ4/9YPxdPoMumPgY= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spiegel-im-spiegel/errs v0.3.2 h1:D4jUouZHBto4Vg+kxc0QNChf3aMynM3FDMNPAq64i2U= +github.com/spiegel-im-spiegel/errs v0.3.2/go.mod h1:NwHSe6m3oAhRj2bAkkbzz9xAffIDNcP9uTdyJd9fJNs= +github.com/spiegel-im-spiegel/gocli v0.10.1 h1:XWyq4dKFp2xTjiH2P2bxPZyi0++4IHp9HOksgGdfwpA= +github.com/spiegel-im-spiegel/gocli v0.10.1/go.mod h1:9vRvly2giutJ2sAtQjrw570p9ulJA3twgKlurmnj12g= +github.com/spiegel-im-spiegel/gprompt v0.9.6 h1:z9FbI6dQlCXFesmxrkgR9EPwaCj/ZpSBNDKBF+NLHX0= +github.com/spiegel-im-spiegel/gprompt v0.9.6/go.mod h1:3FzrLLlQfltS0jqtZA065/rFhOsgqogSxzvgmZb8QUE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 h1:N66aaryRB3Ax92gH0v3hp1QYZ3zWWCCUR/j8Ifh45Ss= +golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/mklink.go b/mklink.go index 12171ca..61cf029 100644 --- a/mklink.go +++ b/mklink.go @@ -12,7 +12,7 @@ import ( "github.com/PuerkitoBio/goquery" encoding "github.com/mattn/go-encoding" - "github.com/spiegel-im-spiegel/mklink/errs" + "github.com/spiegel-im-spiegel/errs" "golang.org/x/net/html/charset" ) diff --git a/mklink.png b/mklink.png deleted file mode 100644 index 812d71c..0000000 Binary files a/mklink.png and /dev/null differ diff --git a/style.go b/style.go index 7fcd22d..695dc47 100644 --- a/style.go +++ b/style.go @@ -3,7 +3,7 @@ package mklink import ( "strings" - "github.com/spiegel-im-spiegel/mklink/errs" + "github.com/spiegel-im-spiegel/errs" ) //Style as link style @@ -50,7 +50,7 @@ func GetStyle(s string) (Style, error) { return t, nil } } - return StyleUnknown, errs.Wrapf(errs.ErrNoImplement, "error in \"%v\" style", s) + return StyleUnknown, errs.Wrap(ErrNoImplement, "", errs.WithContext("style", s)) } func (t Style) String() string { diff --git a/style_test.go b/style_test.go index 9cd21bb..5b07685 100644 --- a/style_test.go +++ b/style_test.go @@ -1,11 +1,9 @@ package mklink import ( + "errors" "fmt" "testing" - - "github.com/spiegel-im-spiegel/mklink/errs" - errors "golang.org/x/xerrors" ) type typesTestCase struct { @@ -34,8 +32,8 @@ func TestGetStyle(t *testing.T) { func TestGetStyleErr(t *testing.T) { tps, err := GetStyle("foobar") fmt.Printf("Info(TestGetStyleErr): %+v\n", err) - if !errors.Is(err, errs.ErrNoImplement) { - t.Errorf("GetStyles(foobar) error = \"%v\", want \"%v\".", err, errs.ErrNoImplement) + if !errors.Is(err, ErrNoImplement) { + t.Errorf("GetStyles(foobar) error = \"%v\", want \"%v\".", err, ErrNoImplement) } else if tps.String() != "unknown" { t.Errorf("GetStyles(foobar) = \"%v\", want \"unknown\".", tps) }