Skip to content

Commit 6a8719e

Browse files
committed
Output the generator in the current directory instead of /tmp.
Updates #11 Updates #10
1 parent 6d37264 commit 6a8719e

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

cmd/struct2ts/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"math/rand"
88
"os"
99
"os/exec"
10-
"path/filepath"
1110
"strings"
1211
"time"
1312

@@ -160,11 +159,13 @@ func render() ([]byte, error) {
160159

161160
func tempFile() (f *os.File, err error) {
162161
// if this somehow conflicts, god really hates us.
163-
fpath := filepath.Join(os.TempDir(), fmt.Sprintf("s2ts_gen_%d_%d.go", time.Now().UnixNano(), rand.Int63()))
162+
fpath := fmt.Sprintf("./s2ts_gen_%d_%d.go", time.Now().UnixNano(), rand.Int63())
164163
return os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
165164
}
166165

167166
const fileTmpl = `// this file was automatically generated using struct2ts {{.cmd}}
167+
// +build ignore
168+
168169
package {{.pkgName}}
169170
170171
import (

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
module github.com/OneOfOne/struct2ts
2+
3+
go 1.11
4+
5+
require (
6+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
7+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
8+
github.com/stretchr/testify v1.3.0 // indirect
9+
golang.org/x/tools v0.0.0-20190208222737-3744606dbb67
10+
gopkg.in/alecthomas/kingpin.v2 v2.2.6
11+
)

go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
2+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
3+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
4+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
5+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
6+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
11+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
12+
golang.org/x/tools v0.0.0-20190208222737-3744606dbb67 h1:bPP/rGuN1LUM0eaEwo6vnP6OfIWJzJBulzGUiKLjjSY=
13+
golang.org/x/tools v0.0.0-20190208222737-3744606dbb67/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
14+
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
15+
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=

0 commit comments

Comments
 (0)