Popularity
1.4
Stable
Activity
0.0
Stable
13
2
3
Programming language: Go
License: MIT License
Tags:
File Handling
pathtype alternatives and similar packages
Based on the "File Handling" category.
Alternatively, view pathtype alternatives based on common mentions on social networks and blogs.
-
gofs
A cross-platform real-time file synchronization tool out of the box based on Golang -
higgs
A tiny cross-platform Go library to hide/unhide files and directories
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Promo
www.influxdata.com
Do you think we are missing an alternative of pathtype or a related project?
Popular Comparisons
README
pathtype
Treat paths as their own type instead of using strings. This small package wraps functions from the standard library to create a new Path type.
Example
Code
package main
import (
"fmt"
"log"
pt "github.com/jonchun/pathtype"
)
type path = pt.Path
func main() {
myFile := path("myfile.txt")
exampleFile := path("example/example.txt")
fmt.Println(exampleFile.Dir())
fmt.Println(exampleFile.Dir().Join(myFile))
res, err := exampleFile.Dir().Join(myFile).Dir().Abs()
if err != nil {
log.Fatal(err)
}
fmt.Println(res)
fmt.Println("=========================")
listBase(res)
fmt.Println("=========================")
listExt(res)
}
// list all Base for files in p
func listBase(p path) {
if glob, err := p.Glob("*"); err != nil {
log.Fatal(err)
} else {
for _, match := range glob {
fmt.Println(match.Base())
}
}
}
// list all extensions for files in p
func listExt(p path) {
if glob, err := p.Glob("*"); err != nil {
log.Fatal(err)
} else {
for _, match := range glob {
fmt.Println(match.Ext())
}
}
}
Output
example
example/myfile.txt
/home/jonchun/example_module/example
=========================
1.log
2.log
example.txt
=========================
.log
.log
.txt
See GoDoc for documentation, but it should be pretty self-explanatory.
TODO
- Update examples for all the methods and have 1-to-1 coverage of the official examples/docs.