-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👔 up: fsutil - add new func: JoinPaths3, update some tests
- Loading branch information
Showing
5 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package comfunc | ||
|
||
import "path/filepath" | ||
|
||
// JoinPaths2 elements, like the filepath.Join() | ||
func JoinPaths2(basePath string, elems []string) string { | ||
paths := make([]string, len(elems)+1) | ||
paths[0] = basePath | ||
copy(paths[1:], elems) | ||
return filepath.Join(paths...) | ||
} | ||
|
||
// JoinPaths3 elements, like the filepath.Join() | ||
func JoinPaths3(basePath, secPath string, elems []string) string { | ||
paths := make([]string, len(elems)+2) | ||
paths[0] = basePath | ||
paths[1] = secPath | ||
copy(paths[2:], elems) | ||
return filepath.Join(paths...) | ||
} |