projects
/
cmccabe-bin
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Makefile: add pickrand
[cmccabe-bin]
/
path-fixer.go
1
package main
2
3
import (
4
"fmt"
5
"os"
6
"strings"
7
)
8
9
func main() {
10
path := os.Getenv("PATH")
11
entries := make(map[string]bool)
12
var bld strings.Builder
13
prefix := ""
14
for {
15
index := strings.Index(path, ":")
16
var entry string
17
if index >= 0 {
18
entry = path[:index]
19
} else {
20
entry = path
21
}
22
if !entries[entry] {
23
entries[entry] = true
24
bld.WriteString(prefix)
25
prefix = ":"
26
bld.WriteString(entry)
27
}
28
if index < 0 {
29
break
30
} else {
31
path = path[index+1:]
32
}
33
}
34
fmt.Printf("%s", bld.String())
35
}