apple / pkl-go

Pkl bindings for the Go programming language
https://pkl-lang.org/go/current/index.html
Apache License 2.0
249 stars 21 forks source link

Fix: use path/filepath package instead of path package #57

Closed candy12t closed 1 month ago

candy12t commented 1 month ago

don't use path package for operating system paths. use path/filepath package instead of path package.

bioball commented 1 month ago

I think path/filepath is the platform-independent API, whereas path uses / path separators. And I believe we do want \ as our path separator on Windows, so this seems like a good change to me?

See godoc: https://pkg.go.dev/path#pkg-overview And https://pkg.go.dev/path/filepath#pkg-overview

candy12t commented 1 month ago

@holzensp Thank you for the comment. As @bioball said, we want to use \ instead of / as path separator on Windows. And, as described in the docs, it's better to use path/filepath package for operating system paths and path package for path operations such as URLs.

Package filepath implements utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths. The filepath package uses either forward slashes or backslashes, depending on the operating system. To process paths such as URLs that always use forward slashes regardless of the operating system, see the path package.