Debian Codegraph @

pkg/envars/envars.go

raw symbols SCIP
1 // Copyright (c) Bartłomiej Płotka @bwplotka
2 // Licensed under the Apache License 2.0.
3
4 package envarsscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/
5
6 import (
7 "stringsscip-go gomod github.com/golang/go/src go1.24.9 strings/"
8
9 "mvdan.cc/sh/v3/expandscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/"
10 )
11
12 type EnvSlicescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice# []string
13
14 func (e EnvSlicescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#) Lookupscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#Lookup().(k string) (string, bool) {
15 for _, ev := range e {
16 sp := stringsscip-go gomod github.com/golang/go/src go1.24.9 strings/.SplitNscip-go gomod github.com/golang/go/src go1.24.9 strings/SplitN().(ev, "=", 2)
17 if sp[0] == k {
18 return sp[1], true
19 }
20 }
21 return "", false
22 }
23
24 func (e *EnvSlicescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#) Setscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#Set().(kvs ...string) {
25 *e = MergeEnvSlicesscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/MergeEnvSlices().(*e, kvs...)
26 }
27
28 // Get retrieves a variable by its name. To check if the variable is
29 // set, use Variable.IsSet.
30 func (e *EnvSlicescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#) Getscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#Get().(name string) expandscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/.Variablescip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/Variable# {
31 return expandscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/.ListEnvironscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/ListEnviron().(*e...).Getscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/Environ#Get().(name)
32 }
33
34 // Each iterates over all the currently set variables, calling the
35 // supplied function on each variable. Iteration is stopped if the
36 // function returns false.
37 //
38 // The names used in the calls aren't required to be unique or sorted.
39 // If a variable name appears twice, the latest occurrence takes
40 // priority.
41 //
42 // Each is required to forward exported variables when executing
43 // programs.
44 func (e *EnvSlicescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#) Eachscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo/pkg/envars`/EnvSlice#Each().(f func(name string, vr expandscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/.Variablescip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/Variable#) bool) {
45 expandscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/.ListEnvironscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/ListEnviron().(*e...).Eachscip-go gomod mvdan.cc/sh/v3 v3.12.0 `mvdan.cc/sh/v3/expand`/Environ#Each().(f)
46 }