Skip to content

SKalt/pathlib.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pathlib.go

String types for path manipulation.

Benefits of using string types to represent paths

  1. you can treat paths exactly like strings
  2. String subtypes prevent common mix-ups: the go compiler will warn you about passing a string that could represent a file to a function that accepts a pathlib.Dir argument.
  3. Each string subtype can have associated methods, consolidating functionality from "path/filepath", "os", and "io/fs"

Prior art

Inspired by Python's pathlib and Go's filesystem methods scattered throughout the stdlib.

There are plenty of other ports of pathlib to go, but only one other package one other uses string types to represent paths.

Trade-offs

Using this library adds some overhead compared to using the stdlib functions directly. Rough measurements on my x86_64 machine indicated that linking pathlib adds around a kilobyte to the size of a binary that does nothing except links path/filepath.

About

string types with path-manipulation methods

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •