From 6a8719ec054ca499d18832e82ecfaa0566031d83 Mon Sep 17 00:00:00 2001 From: OneOfOne Date: Sat, 9 Feb 2019 02:25:52 +0200 Subject: [PATCH] Output the generator in the current directory instead of /tmp. Updates #11 Updates #10 --- cmd/struct2ts/main.go | 5 +++-- go.mod | 10 ++++++++++ go.sum | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 go.sum diff --git a/cmd/struct2ts/main.go b/cmd/struct2ts/main.go index b8d2506..d8233a3 100644 --- a/cmd/struct2ts/main.go +++ b/cmd/struct2ts/main.go @@ -7,7 +7,6 @@ import ( "math/rand" "os" "os/exec" - "path/filepath" "strings" "time" @@ -160,11 +159,13 @@ func render() ([]byte, error) { func tempFile() (f *os.File, err error) { // if this somehow conflicts, god really hates us. - fpath := filepath.Join(os.TempDir(), fmt.Sprintf("s2ts_gen_%d_%d.go", time.Now().UnixNano(), rand.Int63())) + fpath := fmt.Sprintf("./s2ts_gen_%d_%d.go", time.Now().UnixNano(), rand.Int63()) return os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600) } const fileTmpl = `// this file was automatically generated using struct2ts {{.cmd}} +// +build ignore + package {{.pkgName}} import ( diff --git a/go.mod b/go.mod index 542869e..0388e57 100644 --- a/go.mod +++ b/go.mod @@ -1 +1,11 @@ module github.com/OneOfOne/struct2ts + +go 1.11 + +require ( + github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect + github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect + github.com/stretchr/testify v1.3.0 // indirect + golang.org/x/tools v0.0.0-20190208222737-3744606dbb67 + gopkg.in/alecthomas/kingpin.v2 v2.2.6 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b8ae1ae --- /dev/null +++ b/go.sum @@ -0,0 +1,15 @@ +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/tools v0.0.0-20190208222737-3744606dbb67 h1:bPP/rGuN1LUM0eaEwo6vnP6OfIWJzJBulzGUiKLjjSY= +golang.org/x/tools v0.0.0-20190208222737-3744606dbb67/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=