From df511fdfd6d650905d836c02077138c1898c5d80 Mon Sep 17 00:00:00 2001 From: Saswata Mukherjee Date: Fri, 11 Jun 2021 00:27:42 +0530 Subject: [PATCH] Use efficientgo/tools/extkingpin (#39) Signed-off-by: Saswata Mukherjee --- go.mod | 7 +- go.sum | 21 ++- main.go | 2 +- main_test.go | 2 +- pkg/clilog/clilog.go | 2 +- pkg/extflag/pathorcontent.go | 130 ------------------- pkg/mdformatter/linktransformer/link.go | 2 +- pkg/mdformatter/linktransformer/link_test.go | 2 +- pkg/mdformatter/mdformatter.go | 6 +- pkg/mdformatter/mdformatter_test.go | 2 +- pkg/mdformatter/mdgen/mdgen_test.go | 2 +- pkg/mdformatter/transformer.go | 2 +- pkg/transform/transform.go | 8 +- pkg/transform/transform_e2e_test.go | 2 +- pkg/transform/transform_test.go | 2 +- 15 files changed, 30 insertions(+), 162 deletions(-) delete mode 100644 pkg/extflag/pathorcontent.go diff --git a/go.mod b/go.mod index f121403..30fa2ae 100644 --- a/go.mod +++ b/go.mod @@ -4,19 +4,22 @@ go 1.14 require ( github.com/Kunde21/markdownfmt/v2 v2.1.0 - github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect - github.com/efficientgo/tools v0.0.0-20201227131601-4dde9fba2562 + github.com/efficientgo/tools/core v0.0.0-20210609125236-d73259166f20 + github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20 github.com/go-kit/kit v0.10.0 github.com/gobwas/glob v0.2.3 github.com/gocolly/colly/v2 v2.1.0 github.com/gohugoio/hugo v0.74.3 + github.com/kr/pretty v0.2.1 // indirect github.com/mattn/go-shellwords v1.0.10 github.com/mitchellh/mapstructure v1.2.2 // indirect github.com/oklog/run v1.1.0 github.com/pkg/errors v0.9.1 github.com/sergi/go-diff v1.0.0 github.com/yuin/goldmark v1.3.1 + golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect + golang.org/x/tools v0.0.0-20201020161133-226fd2f889ca // indirect gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff --git a/go.sum b/go.sum index 6ff275f..0e7facd 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 h1:AUNCr9CiJuwrRYS3XieqF+Z9B9gNxo/eANAJCF2eiN4= +github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE= github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY= @@ -95,9 +95,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -131,14 +128,15 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/efficientgo/tools v0.0.0-20201227131601-4dde9fba2562 h1:fWqPHUxX1zIL0mB4bsydKzQ0+XYpyvKnzzQJ2oRRjVw= -github.com/efficientgo/tools v0.0.0-20201227131601-4dde9fba2562/go.mod h1:jQUsxCcf91LHRhOnGqrx/yrleJbosynzf29/UlCbzlk= +github.com/efficientgo/tools/core v0.0.0-20210609125236-d73259166f20 h1:3wGt9Bx/h2D/0yOlYIhWB7GmsFBPG9vWDg90UUGgn8c= +github.com/efficientgo/tools/core v0.0.0-20210609125236-d73259166f20/go.mod h1:OmVcnJopJL8d3X3sSXTiypGoUSgFq1aDGmlrdi9dn/M= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20 h1:kM/ALyvAnTrwSB+nlKqoKaDnZbInp1YImZvW+gtHwc8= +github.com/efficientgo/tools/extkingpin v0.0.0-20210609125236-d73259166f20/go.mod h1:ZV0utlglOczUWv3ih2AbqPSoLoFzdplUYxwV62eZi6Q= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanw/esbuild v0.6.5/go.mod h1:mptxmSXIzBIKKCe4jo9A5SToEd1G+AKZ9JmY85dYRJ0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/felixge/fgprof v0.9.1/go.mod h1:7/HK6JFtFaARhIljgP2IV8rJLIoHDoOYoUphsnGvqxE= github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -208,7 +206,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20200615235658-03e1cf38a040/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -254,7 +251,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg= @@ -447,8 +443,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tdewolff/minify/v2 v2.6.2/go.mod h1:BkDSm8aMMT0ALGmpt7j3Ra7nLUgZL0qhyrAHXwxcy5w= github.com/tdewolff/parse/v2 v2.4.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= @@ -580,7 +576,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index c39eb4e..ff90d46 100644 --- a/main.go +++ b/main.go @@ -13,13 +13,13 @@ import ( "syscall" "github.com/bwplotka/mdox/pkg/clilog" - "github.com/bwplotka/mdox/pkg/extflag" "github.com/bwplotka/mdox/pkg/extkingpin" "github.com/bwplotka/mdox/pkg/mdformatter" "github.com/bwplotka/mdox/pkg/mdformatter/linktransformer" "github.com/bwplotka/mdox/pkg/mdformatter/mdgen" "github.com/bwplotka/mdox/pkg/transform" "github.com/bwplotka/mdox/pkg/version" + extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/oklog/run" diff --git a/main_test.go b/main_test.go index 4ff5e30..97b4ba2 100644 --- a/main_test.go +++ b/main_test.go @@ -7,7 +7,7 @@ import ( "os" "testing" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" ) func TestValidateAnchorDir(t *testing.T) { diff --git a/pkg/clilog/clilog.go b/pkg/clilog/clilog.go index 179b4d1..a23fd62 100644 --- a/pkg/clilog/clilog.go +++ b/pkg/clilog/clilog.go @@ -21,7 +21,7 @@ import ( "reflect" "sync" - "github.com/efficientgo/tools/pkg/merrors" + "github.com/efficientgo/tools/core/pkg/merrors" "github.com/go-kit/kit/log" ) diff --git a/pkg/extflag/pathorcontent.go b/pkg/extflag/pathorcontent.go deleted file mode 100644 index 9a6c4ff..0000000 --- a/pkg/extflag/pathorcontent.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) Bartłomiej Płotka @bwplotka -// Licensed under the Apache License 2.0. - -// Taken from Thanos project. -// -// Copyright (c) The Thanos Authors. -// Licensed under the Apache License 2.0. -package extflag - -import ( - "fmt" - "io/ioutil" - "os" - "regexp" - - "github.com/pkg/errors" - "gopkg.in/alecthomas/kingpin.v2" -) - -// PathOrContent is a flag type that defines two flags to fetch bytes. Either from file (*-file flag) or content (* flag). -type PathOrContent struct { - flagName string - - envSubstitution bool - required bool - - path *string - content *string -} - -// Option is a functional option type for PathOrContent objects. -type Option func(*PathOrContent) - -type FlagClause interface { - Flag(name, help string) *kingpin.FlagClause -} - -// RegisterPathOrContent registers PathOrContent flag in kingpinCmdClause. -func RegisterPathOrContent(cmd FlagClause, flagName string, help string, opts ...Option) *PathOrContent { - fileFlagName := fmt.Sprintf("%s-file", flagName) - contentFlagName := flagName - - fileHelp := fmt.Sprintf("Path to %s", help) - fileFlag := cmd.Flag(fileFlagName, fileHelp).PlaceHolder("").String() - - contentHelp := fmt.Sprintf("Alternative to '%s' flag (mutually exclusive). Content of %s", fileFlagName, help) - contentFlag := cmd.Flag(contentFlagName, contentHelp).PlaceHolder("").String() - - p := &PathOrContent{ - flagName: flagName, - path: fileFlag, - content: contentFlag, - required: false, - envSubstitution: false, - } - for _, opt := range opts { - opt(p) - } - return p -} - -// Content returns the content of the file when given or directly the content that has been passed to the flag. -// It returns an error when: -// * The file and content flags are both not empty. -// * The file flag is not empty but the file can't be read. -// * The content is empty and the flag has been defined as required. -func (p *PathOrContent) Content() ([]byte, error) { - fileFlagName := fmt.Sprintf("%s-file", p.flagName) - - if len(*p.path) > 0 && len(*p.content) > 0 { - return nil, errors.Errorf("both %s and %s flags set.", fileFlagName, p.flagName) - } - - var content []byte - if len(*p.path) > 0 { - c, err := ioutil.ReadFile(*p.path) - if err != nil { - return nil, errors.Wrapf(err, "loading file %s for %s", *p.path, fileFlagName) - } - content = c - } else { - content = []byte(*p.content) - } - - if len(content) == 0 && p.required { - return nil, errors.Errorf("flag %s or %s is required for running this command and content cannot be empty.", fileFlagName, p.flagName) - } - if p.envSubstitution { - replace, err := expandEnv(content) - if err != nil { - return nil, err - } - content = replace - } - return content, nil -} - -// WithRequired allows you to override default required option. -func WithRequired() Option { - return func(p *PathOrContent) { - p.required = true - } -} - -// WithRequired allows you to override default envSubstitution option. -func WithEnvSubstitution() Option { - return func(p *PathOrContent) { - p.envSubstitution = true - } -} - -// expandEnv returns content of YAML file with substituted environment variables. -// Follows K8s convention, i.e $(...), as mentioned here https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/. -func expandEnv(b []byte) (r []byte, err error) { - var envRe = regexp.MustCompile(`\$\(([a-zA-Z_0-9]+)\)`) - r = envRe.ReplaceAllFunc(b, func(n []byte) []byte { - if err != nil { - return nil - } - n = n[2 : len(n)-1] - - v, ok := os.LookupEnv(string(n)) - if !ok { - err = errors.Errorf("found reference to unset environment variable %q", n) - return nil - } - return []byte(v) - }) - return r, err -} diff --git a/pkg/mdformatter/linktransformer/link.go b/pkg/mdformatter/linktransformer/link.go index acce8c7..f992750 100644 --- a/pkg/mdformatter/linktransformer/link.go +++ b/pkg/mdformatter/linktransformer/link.go @@ -15,7 +15,7 @@ import ( "sync" "github.com/bwplotka/mdox/pkg/mdformatter" - "github.com/efficientgo/tools/pkg/merrors" + "github.com/efficientgo/tools/core/pkg/merrors" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/gocolly/colly/v2" diff --git a/pkg/mdformatter/linktransformer/link_test.go b/pkg/mdformatter/linktransformer/link_test.go index 880e969..de8dde7 100644 --- a/pkg/mdformatter/linktransformer/link_test.go +++ b/pkg/mdformatter/linktransformer/link_test.go @@ -13,7 +13,7 @@ import ( "testing" "github.com/bwplotka/mdox/pkg/mdformatter" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" "github.com/go-kit/kit/log" ) diff --git a/pkg/mdformatter/mdformatter.go b/pkg/mdformatter/mdformatter.go index 8dc2371..d8915ba 100644 --- a/pkg/mdformatter/mdformatter.go +++ b/pkg/mdformatter/mdformatter.go @@ -13,8 +13,8 @@ import ( "github.com/Kunde21/markdownfmt/v2/markdown" "github.com/bwplotka/mdox/pkg/gitdiff" - "github.com/efficientgo/tools/pkg/errcapture" - "github.com/efficientgo/tools/pkg/merrors" + "github.com/efficientgo/tools/core/pkg/logerrcapture" + "github.com/efficientgo/tools/core/pkg/merrors" "github.com/go-kit/kit/log" "github.com/gohugoio/hugo/parser/pageparser" "github.com/pkg/errors" @@ -210,7 +210,7 @@ func format(ctx context.Context, logger log.Logger, files []string, diffs *Diffs if err != nil { return errors.Wrapf(err, "open %v", fn) } - defer errcapture.CloseWithLog(logger, file, "close file %v", fn) + defer logerrcapture.ExhaustClose(logger, file, "close file %v", fn) b.Reset() if err := f.Format(file, &b); err != nil { diff --git a/pkg/mdformatter/mdformatter_test.go b/pkg/mdformatter/mdformatter_test.go index f7cd061..8cccfbe 100644 --- a/pkg/mdformatter/mdformatter_test.go +++ b/pkg/mdformatter/mdformatter_test.go @@ -10,7 +10,7 @@ import ( "os" "testing" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" "github.com/go-kit/kit/log" ) diff --git a/pkg/mdformatter/mdgen/mdgen_test.go b/pkg/mdformatter/mdgen/mdgen_test.go index 12f3fa3..170bcc8 100644 --- a/pkg/mdformatter/mdgen/mdgen_test.go +++ b/pkg/mdformatter/mdgen/mdgen_test.go @@ -11,7 +11,7 @@ import ( "testing" "github.com/bwplotka/mdox/pkg/mdformatter" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" ) func TestFormat_FormatSingle_CodeBlockTransformer(t *testing.T) { diff --git a/pkg/mdformatter/transformer.go b/pkg/mdformatter/transformer.go index b1f4599..280e2fa 100644 --- a/pkg/mdformatter/transformer.go +++ b/pkg/mdformatter/transformer.go @@ -7,7 +7,7 @@ import ( "bytes" "io" - "github.com/efficientgo/tools/pkg/merrors" + "github.com/efficientgo/tools/core/pkg/merrors" "github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/renderer" "github.com/yuin/goldmark/text" diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index d6ba2ac..5450590 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -14,7 +14,7 @@ import ( "strings" "github.com/bwplotka/mdox/pkg/mdformatter" - "github.com/efficientgo/tools/pkg/errcapture" + "github.com/efficientgo/tools/core/pkg/errcapture" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" @@ -346,7 +346,7 @@ func copyFiles(src, dst string) (err error) { if err != nil { return errors.Wrap(err, "cpy source") } - defer errcapture.Close(&err, source, "src close") + defer errcapture.ExhaustClose(&err, source, "src close") if err := os.MkdirAll(filepath.Dir(dst), os.ModePerm); err != nil { return err @@ -356,7 +356,7 @@ func copyFiles(src, dst string) (err error) { if err != nil { return errors.Wrap(err, "cpy dest") } - defer errcapture.Close(&err, destination, "dst close") + defer errcapture.ExhaustClose(&err, destination, "dst close") _, err = io.Copy(destination, source) return err @@ -369,7 +369,7 @@ func popFirstHeader(path string) (_ string, rest []byte, err error) { if err != nil { return "", nil, err } - defer errcapture.Close(&err, file, "close file") + defer errcapture.ExhaustClose(&err, file, "close file") scanner := bufio.NewScanner(file) for scanner.Scan() { diff --git a/pkg/transform/transform_e2e_test.go b/pkg/transform/transform_e2e_test.go index 131da09..8195806 100644 --- a/pkg/transform/transform_e2e_test.go +++ b/pkg/transform/transform_e2e_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/bwplotka/mdox/pkg/transform" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" "github.com/go-kit/kit/log" "github.com/pkg/errors" ) diff --git a/pkg/transform/transform_test.go b/pkg/transform/transform_test.go index c8372ac..0aea616 100644 --- a/pkg/transform/transform_test.go +++ b/pkg/transform/transform_test.go @@ -7,7 +7,7 @@ import ( "fmt" "testing" - "github.com/efficientgo/tools/pkg/testutil" + "github.com/efficientgo/tools/core/pkg/testutil" "github.com/pkg/errors" )