github.com/golang/dep@v0.5.4/cmd/dep/feature_flags.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 "strconv" 10 ) 11 12 const ( 13 flagImportDuringSolveKey = "ImportDuringSolve" 14 ) 15 16 var ( 17 flagImportDuringSolve = "false" 18 ) 19 20 var featureFlags = map[string]bool{ 21 flagImportDuringSolveKey: parseFeatureFlag(flagImportDuringSolve), 22 } 23 24 func parseFeatureFlag(flag string) bool { 25 flagValue, _ := strconv.ParseBool(flag) 26 return flagValue 27 } 28 29 func readFeatureFlag(flag string) (bool, error) { 30 if flagValue, ok := featureFlags[flag]; ok { 31 return flagValue, nil 32 } 33 34 return false, fmt.Errorf("undefined feature flag: %s", flag) 35 } 36 37 func importDuringSolve() bool { 38 return featureFlags[flagImportDuringSolveKey] 39 }