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
5package main
6
7import (
8	"fmt"
9	"strconv"
10)
11
12const (
13	flagImportDuringSolveKey = "ImportDuringSolve"
14)
15
16var (
17	flagImportDuringSolve = "false"
18)
19
20var featureFlags = map[string]bool{
21	flagImportDuringSolveKey: parseFeatureFlag(flagImportDuringSolve),
22}
23
24func parseFeatureFlag(flag string) bool {
25	flagValue, _ := strconv.ParseBool(flag)
26	return flagValue
27}
28
29func 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
37func importDuringSolve() bool {
38	return featureFlags[flagImportDuringSolveKey]
39}
40