There are two additional options I can think of:
- store
path.Join
in a variable
- make
path
a type that implements Join
The first is simple. Instead of path.Join
you store path.Join
in a variable before declaring path
and call it instead (play):
join := path.Join
path := "/some/path"
path = join("/some/other/path")
The second is a bit more complicated and I don't think you should actually do that but it is a possibility
(play):
type Path string
func (p Path) Join(elem ...string) string {
return path.Join(append([]string{string(p)}, elem...)...)
}
fmt.Println("Hello, playground")
path := "/some/path"
path = Path(path).Join("/some/other/path")