Allows for early version to be included without tagging a repository. One place to set the version.
package example
import (
_ "embed"
"strings"
)
func Version() string {
prefix := "## ["
from := strings.Index(changelog, prefix) + len(prefix)
to := from + strings.Index(changelog[from:], "]")
return changelog[from:to]
}
//go:embed changelog.md
var changelog string
The above code will parse the version from the top most section from a
changelog file like this
# Changelog .... ## [0.1.1-dev] - wip... ## [0.1.0] 2024-01-01 - first entry