本文整理汇总了Golang中utilz/global.GetBool函数的典型用法代码示例。如果您正苦于以下问题:Golang GetBool函数的具体用法?Golang GetBool怎么用?Golang GetBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetBool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: External
func (d Dag) External(update bool) {
var argv []string
var set *stringset.StringSet
var i int = 0
set = d.Alien()
argv = make([]string, 0)
argv = append(argv, "go")
argv = append(argv, "get")
if global.GetBool("-verbose") {
argv = append(argv, "-v")
}
if update {
argv = append(argv, "-u")
}
argv = append(argv, "-a")
i = len(argv)
argv = append(argv, "dummy")
for u := range set.Iter() {
argv[i] = u
if global.GetBool("-dryrun") {
fmt.Printf("%s || exit 1\n", strings.Join(argv, " "))
} else {
say.Printf("go get: %s\n", u)
handy.StdExecve(argv, true)
}
}
}
示例2: External
func (d Dag) External() {
var err os.Error
var argv []string
var tmp string
var set *stringset.StringSet
var i int = 0
set = stringset.New()
for _, v := range d {
for dep := range v.dependencies.Iter() {
if !d.localDependency(dep) {
set.Add(dep)
}
}
}
for u := range set.Iter() {
if !seemsExternal(u) {
set.Remove(u)
}
}
argv = make([]string, 0)
tmp, err = exec.LookPath("goinstall")
if err != nil {
log.Fatalf("[ERROR] %s\n", err)
}
argv = append(argv, tmp)
if global.GetBool("-verbose") {
argv = append(argv, "-v=true")
}
argv = append(argv, "-u=true")
argv = append(argv, "-clean=true")
i = len(argv)
argv = append(argv, "dummy")
for u := range set.Iter() {
argv[i] = u
if global.GetBool("-dryrun") {
fmt.Printf("%s || exit 1\n", strings.Join(argv, " "))
} else {
say.Printf("goinstall: %s\n", u)
handy.StdExecve(argv, true)
}
}
}
示例3: Remove865o
func Remove865o(dir string, alsoDir bool) {
// override IncludeFile to make walker pick up .[865] .o .vmo
walker.IncludeFile = func(s string) bool {
return strings.HasSuffix(s, ".8") ||
strings.HasSuffix(s, ".6") ||
strings.HasSuffix(s, ".5") ||
strings.HasSuffix(s, ".o") ||
strings.HasSuffix(s, ".vmo")
}
handy.DirOrExit(dir)
compiled := walker.PathWalk(filepath.Clean(dir))
for i := 0; i < len(compiled); i++ {
shortName := compiled[i]
pwd, e := os.Getwd()
if e == nil {
if strings.HasPrefix(compiled[i], pwd) {
shortName = shortName[len(pwd)+1:]
}
}
if !global.GetBool("-dryrun") {
e := os.Remove(compiled[i])
if e != nil {
log.Printf("[ERROR] could not delete file: %s\n", compiled[i])
} else {
say.Printf("rm: %s\n", shortName)
}
} else {
fmt.Printf("[dryrun] rm: %s\n", shortName)
}
}
if alsoDir {
// remove entire dir if empty after objects are deleted
walker.IncludeFile = func(s string) bool { return true }
walker.IncludeDir = func(s string) bool { return true }
if len(walker.PathWalk(dir)) == 0 {
if global.GetBool("-dryrun") {
fmt.Printf("[dryrun] rm: %s\n", dir)
} else {
say.Printf("rm: %s\n", dir)
e := os.RemoveAll(dir)
if e != nil {
log.Fatalf("[ERROR] %s\n", e)
}
}
}
}
}
示例4: FormatFiles
func FormatFiles(files []string) {
var i int
var argv []string
var tabWidth string = "-tabwidth=4"
var useTabs string = "-tabindent=false"
var rewRule string = global.GetString("-rew-rule")
var fmtexec string
var err os.Error
fmtexec, err = exec.LookPath("gofmt")
if err != nil {
log.Fatal("[ERROR] could not find 'gofmt' in $PATH")
}
if global.GetString("-tabwidth") != "" {
tabWidth = "-tabwidth=" + global.GetString("-tabwidth")
}
if global.GetBool("-tab") {
useTabs = "-tabindent=true"
}
argv = make([]string, 0)
argv = append(argv, fmtexec)
argv = append(argv, "-w=true")
argv = append(argv, tabWidth)
argv = append(argv, useTabs)
if rewRule != "" {
argv = append(argv, fmt.Sprintf("-r='%s'", rewRule))
}
argv = append(argv, "") // dummy
i = len(argv) - 1
for y := 0; y < len(files); y++ {
argv[i] = files[y]
if global.GetBool("-dryrun") {
argv[0] = filepath.Base(argv[0])
fmt.Printf(" %s\n", strings.Join(argv, " "))
} else {
say.Printf("gofmt: %s\n", files[y])
_ = handy.StdExecve(argv, true)
}
}
}
示例5: CreateTestArgv
func CreateTestArgv() []string {
pwd, e := os.Getwd()
if e != nil {
log.Fatal("[ERROR] could not locate working directory\n")
}
argv := make([]string, 0)
if global.GetString("-backend") == "express" {
vmrun, e := exec.LookPath("vmrun")
if e != nil {
log.Fatalf("[ERROR] %s\n", e)
}
argv = append(argv, vmrun)
}
argv = append(argv, filepath.Join(pwd, global.GetString("-test-bin")))
if global.GetString("-bench") != "" {
argv = append(argv, "-test.bench")
argv = append(argv, global.GetString("-bench"))
}
if global.GetString("-match") != "" {
argv = append(argv, "-test.run")
argv = append(argv, global.GetString("-match"))
}
if global.GetBool("-verbose") {
argv = append(argv, "-test.v")
}
return argv
}
示例6: DeletePackages
// for removal of temoprary packages created for testing and so on..
func DeletePackages(pkgs []*dag.Package) bool {
var ok = true
var e os.Error
for i := 0; i < len(pkgs); i++ {
for y := 0; y < len(pkgs[i].Files); y++ {
e = os.Remove(pkgs[i].Files[y])
if e != nil {
ok = false
log.Printf("[ERROR] %s\n", e)
}
}
if !global.GetBool("-dryrun") {
pcompile := filepath.Join(libroot, pkgs[i].Name) + suffix
e = os.Remove(pcompile)
if e != nil {
ok = false
log.Printf("[ERROR] %s\n", e)
}
}
}
return ok
}
示例7: DeleteObjects
func DeleteObjects(dir string, pkgs []*dag.Package) {
var stub, tmp string
suffixes := []string{".8", ".6", ".5", ".o", ".vmo"}
libdir := global.GetString("-lib")
if libdir != "" {
dir = libdir
}
for i := 0; i < len(pkgs); i++ {
stub = filepath.Join(dir, pkgs[i].Name)
for j := 0; j < len(suffixes); j++ {
tmp = stub + suffixes[j]
if handy.IsFile(tmp) {
if global.GetBool("-dryrun") {
say.Printf("[dryrun] rm: %s\n", tmp)
} else {
say.Printf("rm: %s\n", tmp)
handy.Delete(tmp, false)
}
}
}
}
// remove entire dir if empty after objects are deleted.
// only do this if -lib is present, there is no reason to
// do this (extra treewalk) if objects are in src directory
if libdir != "" && handy.IsDir(dir) {
walker.IncludeFile = func(s string) bool { return true }
walker.IncludeDir = func(s string) bool { return true }
if len(walker.PathWalk(dir)) == 0 {
if global.GetBool("-dryrun") {
fmt.Printf("[dryrun] rm: %s\n", dir)
} else {
say.Printf("rm: %s\n", dir)
handy.RmRf(dir, true) // die on error
}
}
}
}
示例8: External
func (d Dag) External() {
var err os.Error
var argv []string
var tmp string
var set *stringset.StringSet
var i int = 0
set = d.Alien()
argv = make([]string, 0)
tmp, err = exec.LookPath("goinstall")
if err != nil {
log.Fatalf("[ERROR] %s\n", err)
}
argv = append(argv, tmp)
if global.GetBool("-verbose") {
argv = append(argv, "-v=true")
}
argv = append(argv, "-u=true")
argv = append(argv, "-clean=true")
i = len(argv)
argv = append(argv, "dummy")
for u := range set.Iter() {
argv[i] = u
if global.GetBool("-dryrun") {
fmt.Printf("%s || exit 1\n", strings.Join(argv, " "))
} else {
say.Printf("goinstall: %s\n", u)
handy.StdExecve(argv, true)
}
}
}
示例9: UpToDate
func (p *Package) UpToDate() bool {
if p.Argv == nil {
log.Fatalf("[ERROR] missing dag.Package.Argv\n")
}
var e os.Error
var finfo *os.FileInfo
var compiledModifiedTime int64
var last, stop, i int
var resultingFile string
last = len(p.Argv) - 1
stop = last - len(p.Files)
resultingFile = p.Argv[stop]
finfo, e = os.Stat(resultingFile)
if e != nil {
return false
} else {
compiledModifiedTime = finfo.Mtime_ns
}
for i = last; i > stop; i-- {
finfo, e = os.Stat(p.Argv[i])
if e != nil {
panic(fmt.Sprintf("Missing go file: %s\n", p.Argv[i]))
} else {
if finfo.Mtime_ns > compiledModifiedTime {
return false
}
}
}
// package contains _test.go and -test => not UpToDate
if global.GetBool("-test") {
testpkgs := 0
for i = 0; i < len(p.Files); i++ {
if strings.HasSuffix(p.Files[i], "_test.go") {
testpkgs++
}
}
if testpkgs > 0 && testpkgs != len(p.Files) {
return false
}
}
return true
}
示例10: printListing
func printListing() {
fmt.Println("\n Listing of options and their content:\n")
defer fmt.Println("")
for i := 0; i < len(bools); i++ {
fmt.Printf(" %-20s => %v\n", bools[i], global.GetBool(bools[i]))
}
for i := 0; i < len(strs); i++ {
fmt.Printf(" %-20s => %v\n", strs[i], global.GetString(strs[i]))
}
fmt.Printf(" %-20s => %v\n", "-lib", includes)
}
示例11: DeletePackages
// for removal of temoprary packages created for testing and so on..
func DeletePackages(pkgs []*dag.Package) bool {
var ok = true
for i := 0; i < len(pkgs); i++ {
for y := 0; y < len(pkgs[i].Files); y++ {
handy.Delete(pkgs[i].Files[y], false)
}
if !global.GetBool("-dryrun") {
pcompile := filepath.Join(libroot, pkgs[i].Name) + suffix
ok = handy.Delete(pcompile, false)
}
}
return ok
}
示例12: SerialCompile
func SerialCompile(pkgs []*dag.Package) {
var oldPkgFound bool = false
for y := 0; y < len(pkgs); y++ {
if global.GetBool("-dryrun") {
fmt.Printf("%s || exit 1\n", strings.Join(pkgs[y].Argv, " "))
} else {
if oldPkgFound || !pkgs[y].UpToDate() {
say.Println("compiling:", pkgs[y].Name)
handy.StdExecve(pkgs[y].Argv, true)
oldPkgFound = true
} else {
say.Println("up 2 date:", pkgs[y].Name)
}
}
}
}
示例13: ForkLink
func ForkLink(output string, pkgs []*dag.Package, extra []*dag.Package, up2date bool) {
var mainPKG *dag.Package
gotMain := make([]*dag.Package, 0)
for i := 0; i < len(pkgs); i++ {
if pkgs[i].ShortName == "main" {
gotMain = append(gotMain, pkgs[i])
}
}
if len(gotMain) == 0 {
log.Fatal("[ERROR] (linking) no main package found\n")
}
if len(gotMain) > 1 {
choice := mainChoice(gotMain)
mainPKG = gotMain[choice]
} else {
mainPKG = gotMain[0]
}
compiled := filepath.Join(libroot, mainPKG.Name) + suffix
if up2date && !global.GetBool("-dryrun") && handy.IsFile(output) {
if handy.ModifyTimestamp(compiled) < handy.ModifyTimestamp(output) {
say.Printf("up 2 date: %s\n", output)
return
}
}
argv := make([]string, 0)
argv = append(argv, pathLinker)
switch global.GetString("-backend") {
case "gc", "express":
argv = append(argv, "-L")
argv = append(argv, libroot)
}
argv = append(argv, "-o")
argv = append(argv, output)
// gcc get's this no matter what...
if global.GetString("-backend") == "gcc" ||
global.GetString("-backend") == "gccgo" {
argv = append(argv, "-static")
} else if global.GetBool("-static") {
argv = append(argv, "-d")
}
switch global.GetString("-backend") {
case "gccgo", "gcc":
walker.IncludeFile = func(s string) bool {
return strings.HasSuffix(s, ".o")
}
walker.IncludeDir = func(s string) bool { return true }
for y := 0; y < len(includes); y++ {
argv = append(argv, walker.PathWalk(includes[y])...)
}
case "gc", "express":
for y := 0; y < len(includes); y++ {
argv = append(argv, "-L")
argv = append(argv, includes[y])
}
}
argv = append(argv, compiled)
if global.GetString("-backend") == "gcc" ||
global.GetString("-backend") == "gccgo" {
ss := stringset.New()
if len(extra) > 0 {
for j := 0; j < len(extra); j++ {
// main package untestable using GCC
if extra[j].ShortName != "main" {
ss.Add(filepath.Join(libroot, extra[j].Name) + suffix)
}
}
} else {
for k := 0; k < len(pkgs); k++ {
ss.Add(filepath.Join(libroot, pkgs[k].Name) + suffix)
}
ss.Remove(compiled)
}
if ss.Len() > 0 {
argv = append(argv, ss.Slice()...)
}
}
if global.GetBool("-dryrun") {
linker := filepath.Base(pathLinker)
fmt.Printf("%s %s || exit 1\n", linker, strings.Join(argv[1:], " "))
} else {
say.Println("linking :", output)
//.........这里部分代码省略.........
示例14: printListing
func printListing() {
var listMSG string = `
Listing of options and their content:
-h --help => %t
-v --version => %t
-p --print => %t
-s --sort => %t
-o --output => '%s'
-S --static => %t
-a --arch => %v
-d --dryrun => %t
-c --clean => %t
-q --quiet => %t
-L --lib => '%s'
-M --main => '%s'
-I => %v
-dot => '%s'
-t --test => %t
-b --bench => '%s'
-m --match => '%s'
-V --verbose => %t
--test-bin => '%s'
-f --fmt => %t
--rew-rule => '%s'
--tab => %t
--tabwidth => %s
-e --external => %t
-B --backend => '%s'
`
tabRepr := "4"
if global.GetString("-tabwidth") != "" {
tabRepr = global.GetString("-tabwidth")
}
archRepr := "$GOARCH"
if global.GetString("-arch") != "" {
archRepr = global.GetString("-arch")
}
fmt.Printf(listMSG,
global.GetBool("-help"),
global.GetBool("-version"),
global.GetBool("-print"),
global.GetBool("-sort"),
global.GetString("-output"),
global.GetBool("-static"),
archRepr,
global.GetBool("-dryrun"),
global.GetBool("-clean"),
global.GetBool("-quiet"),
global.GetString("-lib"),
global.GetString("-main"),
includes,
global.GetString("-dot"),
global.GetBool("-test"),
global.GetString("-bench"),
global.GetString("-match"),
global.GetBool("-verbose"),
global.GetString("-test-bin"),
global.GetBool("-fmt"),
global.GetString("-rew-rule"),
global.GetBool("-tab"),
tabRepr,
global.GetBool("-external"),
global.GetString("-backend"))
}
示例15: main
func main() {
var ok bool
var e os.Error
var argv, args []string
var config1, config2 string
timer.Start("everything")
defer reportTime()
// default config location 1 $HOME/.gdrc
config1 = filepath.Join(os.Getenv("HOME"), ".gdrc")
argv, ok = handy.ConfigToArgv(config1)
if ok {
args = parseArgv(argv)
if len(args) > 0 {
log.Print("[WARNING] non-option arguments in config file\n")
}
}
// default config location 2 $PWD/.gdrc
config2 = filepath.Join(os.Getenv("PWD"), ".gdrc")
argv, ok = handy.ConfigToArgv(config2)
if ok {
args = parseArgv(argv)
if len(args) > 0 {
log.Print("[WARNING] non-option arguments in config file\n")
}
}
// command line arguments overrides/appends config
args = parseArgv(os.Args[1:])
if len(args) > 0 {
if len(args) > 1 {
log.Print("[WARNING] len(input directories) > 1\n")
}
srcdir = args[0]
if srcdir == "." {
srcdir, e = os.Getwd()
if e != nil {
log.Fatal("[ERROR] can't find working directory\n")
}
}
}
// expand variables in includes
for i := 0; i < len(includes); i++ {
includes[i] = os.ShellExpand(includes[i])
}
// expand variables in -lib
global.SetString("-lib", os.ShellExpand(global.GetString("-lib")))
// expand variables in -output
global.SetString("-output", os.ShellExpand(global.GetString("-output")))
// stuff that can be done without $GOROOT
if global.GetBool("-list") {
printListing()
os.Exit(0)
}
if global.GetBool("-help") {
printHelp()
os.Exit(0)
}
if global.GetBool("-version") {
printVersion()
os.Exit(0)
}
if len(args) == 0 {
// give nice feedback if missing input dir
cwd, e := os.Getwd()
if e != nil {
cwd = os.Getenv("PWD")
}
possibleSrc := cwd
_, e = os.Stat(possibleSrc)
srcdir, e = os.Getwd()
if e != nil {
fmt.Printf("usage: gd [OPTIONS] src-directory\n")
os.Exit(1)
}
}
if global.GetBool("-quiet") {
say.Mute()
}
// delete all object/archive files
if global.GetBool("-clean") {
compiler.Remove865o(srcdir, false) // do not remove dir
if global.GetString("-lib") != "" {
if handy.IsDir(global.GetString("-lib")) {
compiler.Remove865o(global.GetString("-lib"), true)
//.........这里部分代码省略.........