Modulize project

for/master
Dustin Oprea 2020-01-01 10:53:20 -05:00
parent 0b891977a5
commit 8fd2b91cd6
4 changed files with 52 additions and 9 deletions

View File

@ -160,12 +160,20 @@ func validateExifSimpleTestIb(exifData []byte, t *testing.T) {
}
func init() {
goPath := os.Getenv("GOPATH")
if goPath == "" {
log.Panicf("GOPATH is empty")
}
// This will only be executed when we're running tests in this package and
// not when this package is being imported from a subpackage.
assetsPath = path.Join(goPath, "src", "github.com", "dsoprea", "go-exif", "assets")
goPath := os.Getenv("GOPATH")
if goPath != "" {
assetsPath = path.Join(goPath, "src", "github.com", "dsoprea", "go-exif", "assets")
} else {
// Module-enabled context.
currentWd, err := os.Getwd()
log.PanicIf(err)
assetsPath = path.Join(currentWd, "assets")
}
testImageFilepath = path.Join(assetsPath, "NDM_8901.jpg")

View File

@ -146,11 +146,21 @@ func TestMainJson(t *testing.T) {
func init() {
goPath := os.Getenv("GOPATH")
if goPath == "" {
log.Panicf("GOPATH is empty")
moduleRoot := ""
if goPath != "" {
moduleRoot = path.Join(goPath, "src", "github.com", "dsoprea", "go-exif")
} else {
// Module-enabled context.
currentWd, err := os.Getwd()
log.PanicIf(err)
moduleRoot = path.Join(currentWd, "..")
}
assetsPath = path.Join(goPath, "src", "github.com", "dsoprea", "go-exif", "assets")
appFilepath = path.Join(goPath, "src", "github.com", "dsoprea", "go-exif", "exif-read-tool", "main.go")
assetsPath = path.Join(moduleRoot, "assets")
appFilepath = path.Join(moduleRoot, "exif-read-tool", "main.go")
testImageFilepath = path.Join(assetsPath, "NDM_8901.jpg")
}

11
go.mod Normal file
View File

@ -0,0 +1,11 @@
module github.com/dsoprea/go-exif
go 1.13
require (
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696
github.com/go-errors/errors v1.0.1 // indirect
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
gopkg.in/yaml.v2 v2.2.7
)

14
go.sum Normal file
View File

@ -0,0 +1,14 @@
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696 h1:VGFnZAcLwPpt1sHlAxml+pGLZz9A2s+K/s1YNhPC91Y=
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696/go.mod h1:Nm/x2ZUNRW6Fe5C3LxdY1PyZY5wmDv/s5dkPJ/VB3iA=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec h1:lJwO/92dFXWeXOZdoGXgptLmNLwynMSHUmU6besqtiw=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=