MCPcopy Create free account
hub / github.com/celer-pkg/celer / JoinPaths

Function JoinPaths

pkgs/env/env.go:11–37  ·  view source on GitHub ↗

JoinPaths it'll filter the paths that are already in the runtimePaths, and append them to the end of the finalPaths.

(envkey string, paths ...string)

Source from the content-addressed store, hash-verified

9// JoinPaths it'll filter the paths that are already in the runtimePaths,
10// and append them to the end of the finalPaths.
11func JoinPaths(envkey string, paths ...string) string {
12 if strings.TrimSpace(envkey) == "" {
13 panic("envkey is empty when JoinPaths.")
14 }
15 separator := string(os.PathListSeparator)
16
17 var finalPaths []string
18 var currentPaths []string
19
20 path := os.Getenv(envkey)
21 if path != "" {
22 currentPaths = strings.Split(path, separator)
23 }
24
25 // Filter paths that are not in runtimePaths.
26 for _, path := range paths {
27 if !slices.Contains(currentPaths, path) {
28 finalPaths = append(finalPaths, path)
29 }
30 }
31
32 // Merge runtimePaths to the end of finalPaths.
33 if len(currentPaths) > 0 {
34 finalPaths = append(finalPaths, currentPaths...)
35 }
36 return strings.Join(finalPaths, separator)
37}
38
39// JoinSpace Joins the paths with space.
40func JoinSpace(paths ...string) string {

Callers 13

ValidateMethod · 0.92
ValidateMethod · 0.92
DetectMethod · 0.92
validateMethod · 0.92
SetupMethod · 0.92
preConfigureMethod · 0.92
setupEnvsMethod · 0.92
setupRuntimePathMethod · 0.92
setupPythonEnvsMethod · 0.92
CleanEnvFunction · 0.92
AppendPythonBinDirFunction · 0.92
CleanEnvFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected