MCPcopy Create free account
hub / github.com/jwilder/dockerize / defaultValue

Function defaultValue

template.go:36–60  ·  view source on GitHub ↗
(args ...interface{})

Source from the content-addressed store, hash-verified

34}
35
36func defaultValue(args ...interface{}) (string, error) {
37 if len(args) == 0 {
38 return "", fmt.Errorf("default called with no values")
39 }
40
41 if len(args) > 0 {
42 if args[0] != nil {
43 return args[0].(string), nil
44 }
45 }
46
47 if len(args) > 1 {
48 if args[1] == nil {
49 return "", fmt.Errorf("default called with nil default value")
50 }
51
52 if _, ok := args[1].(string); !ok {
53 return "", fmt.Errorf("default is not a string value, hint: surround it with double quotes")
54 }
55
56 return args[1].(string), nil
57 }
58
59 return "", fmt.Errorf("default called with no default value")
60}
61
62func parseUrl(rawurl string) *url.URL {
63 u, err := url.Parse(rawurl)

Callers 1

TestDefaultValueFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestDefaultValueFunction · 0.68