Add filepath
This commit is contained in:
parent
5d73c57919
commit
fc2dc32323
26
filepath/filepath.go
Normal file
26
filepath/filepath.go
Normal file
@ -0,0 +1,26 @@
|
||||
package filepath
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Filepath() {
|
||||
p := filepath.Join("a", "b", "c", "d")
|
||||
fmt.Println(p)
|
||||
|
||||
ext := filepath.Ext("main.go")
|
||||
fmt.Printf("Extension is %s\n", ext)
|
||||
fmt.Printf("Filename without ext is %s\n", strings.TrimSuffix("main.go", ext))
|
||||
|
||||
fmt.Printf("Base name is %s\n", filepath.Base("/a/b/c/file.go"))
|
||||
fmt.Printf("Dirname is %s\n", filepath.Dir("/a/b/c/file.go"))
|
||||
|
||||
relPath, _ := filepath.Rel("/a/b", "/a/c/d/f")
|
||||
fmt.Println("Rel path is", relPath)
|
||||
|
||||
fmt.Println("Is local?", filepath.IsLocal("filepath.go"))
|
||||
fmt.Println("Is abs?", filepath.IsAbs("/a/b/c/d"))
|
||||
fmt.Println("Is abs?", filepath.IsAbs("/a/b/c/d/.."))
|
||||
}
|
6
main.go
6
main.go
@ -36,7 +36,8 @@ package main
|
||||
// import "git.sangeeth.dev/gobyexample/base64"
|
||||
// import "git.sangeeth.dev/gobyexample/files"
|
||||
// import "git.sangeeth.dev/gobyexample/linefilter"
|
||||
import "git.sangeeth.dev/gobyexample/exit"
|
||||
// import "git.sangeeth.dev/gobyexample/exit"
|
||||
import "git.sangeeth.dev/gobyexample/filepath"
|
||||
|
||||
func main() {
|
||||
// runes.Runes()
|
||||
@ -75,5 +76,6 @@ func main() {
|
||||
// base64.Base64()
|
||||
// files.Files()
|
||||
// linefilter.LineFilter()
|
||||
exit.Exit()
|
||||
// exit.Exit()
|
||||
filepath.Filepath()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user