pkl
pkl copied to clipboard
Support Go semver convention
When running go mod tidy, the version must be prefixed with a 'v'. However, the file at https://github.com/apple/pkl/blob/0.25.2/stdlib/Project.pkl#L276 expects the version without the 'v'. Since I've placed the generated Go files in a separate repository, the default behavior of go mod tidy will fail to locate the package if the version is not prefixed with the 'v'.
I have resolved it by defining a regexp on the PklProject
version = read?("env:VERSION").replaceFirst(Regex("^v(\\d+\\.\\d+\\.\\d+)(-[\\w\\.]+)?(\\+[\\w\\.]+)?$"), "$1")
I don't think we will support a leading v, because that leads to ambiguous situations (what do you do if there is both v1.0.0 and 1.0.0?)
Your workaround seems like a good solution!