reformat code with goimports
This commit is contained in:
parent
5304f43067
commit
6da5b2fc5f
@ -1,12 +1,14 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
"os/user"
|
|
||||||
"github.com/codegangsta/cli"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/codegangsta/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Custom type which is registered in the flags library which cli uses for
|
// Custom type which is registered in the flags library which cli uses for
|
||||||
@ -55,6 +57,7 @@ func eachName(longName string, fn func(string)) {
|
|||||||
fn(name)
|
fn(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by cli library, grabs variable from environment (if in env)
|
// called by cli library, grabs variable from environment (if in env)
|
||||||
// and adds variable to flag set for parsing.
|
// and adds variable to flag set for parsing.
|
||||||
func (self DirectoryFlag) Apply(set *flag.FlagSet) {
|
func (self DirectoryFlag) Apply(set *flag.FlagSet) {
|
||||||
@ -69,7 +72,7 @@ func (self DirectoryFlag) Apply(set *flag.FlagSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eachName(self.Name, func(name string) {
|
eachName(self.Name, func(name string) {
|
||||||
set.Var(self.Value, self.Name, "a: " + self.Usage)
|
set.Var(self.Value, self.Name, "a: "+self.Usage)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -128,6 +131,3 @@ func expandPath(p string) string {
|
|||||||
|
|
||||||
return filepath.Clean(os.ExpandEnv(p))
|
return filepath.Clean(os.ExpandEnv(p))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPathExpansion(t *testing.T) {
|
func TestPathExpansion(t *testing.T) {
|
||||||
|
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
|
|
||||||
tests := map[string]string {
|
tests := map[string]string{
|
||||||
"/home/someuser/tmp": "/home/someuser/tmp",
|
"/home/someuser/tmp": "/home/someuser/tmp",
|
||||||
"~/tmp": user.HomeDir + "/tmp",
|
"~/tmp": user.HomeDir + "/tmp",
|
||||||
"$DDDXXX/a/b": "/tmp/a/b",
|
"$DDDXXX/a/b": "/tmp/a/b",
|
||||||
|
Loading…
Reference in New Issue
Block a user