Skip to content

Commit

Permalink
use built-in os.ExpandEnv()
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed Jan 10, 2017
1 parent 7ef385b commit b369228
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
const (
gopath = "$GOPATH"
runArg = "run=%s"
dollar = "$"
)

var (
Expand All @@ -38,19 +37,11 @@ func parseFlags() {

flag.Parse()

var s string

if len(*flagDir) == 0 {
panic("**invalid Input Directory")
}

// ENV variable
if (*flagDir)[:1] == dollar {
s = filepath.Clean(os.Getenv((*flagDir)[1:]))
} else {
s = filepath.Clean(*flagDir)
}

s := filepath.Clean(os.ExpandEnv(*flagDir))
flagDir = &s

if *flagDir == "." {
Expand Down Expand Up @@ -98,7 +89,7 @@ func generate() {

walker := func(path string, info os.FileInfo, err error) error {

if !info.IsDir() {
if info == nil || !info.IsDir() {
return nil
}

Expand Down

0 comments on commit b369228

Please sign in to comment.