From c83687a93226a6f320d5ce591d1a767f6a0fd108 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Wed, 20 Nov 2019 21:58:48 -0500 Subject: [PATCH] copy sum too --- pkging/pkgtest/ref.go | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/pkging/pkgtest/ref.go b/pkging/pkgtest/ref.go index fa421ad..a9a8dca 100644 --- a/pkging/pkgtest/ref.go +++ b/pkging/pkgtest/ref.go @@ -68,32 +68,25 @@ func newRef(root string) (*Ref, error) { return nil, err } - b, err = ioutil.ReadFile(filepath.Join(root, "go.mod")) - if err != nil { - return nil, err - } + for _, n := range []string{"go.mod", "go.sum"} { + b, err = ioutil.ReadFile(filepath.Join(root, n)) + if err != nil { + return nil, err + } - f, err := os.Create(filepath.Join(dir, "go.mod")) - if err != nil { - return nil, err - } + f, err := os.Create(filepath.Join(dir, n)) + if err != nil { + return nil, err + } - if _, err := f.Write(b); err != nil { - return nil, err - } + if _, err := f.Write(b); err != nil { + return nil, err + } - if err := f.Close(); err != nil { - return nil, err + if err := f.Close(); err != nil { + return nil, err + } } - // c := exec.Command("cp", "-rv", root, dir) - // fmt.Println(strings.Join(c.Args, " ")) - // c.Stdout = os.Stdout - // c.Stderr = os.Stderr - // c.Stdin = os.Stdin - // if err := c.Run(); err != nil { - // return nil, err - // } - return ref, nil }