Move packages to root folder
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 33s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 33s
Signed-off-by: Jan Tytgat <jan.tytgat@corelayer.eu>
This commit is contained in:
23
semver/metadata.go
Normal file
23
semver/metadata.go
Normal file
@ -0,0 +1,23 @@
|
||||
package semver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
const (
|
||||
validMetadata = `^(?P<commit>[0-9a-zA-Z]{8}).(?P<date>[0-9]{8})$`
|
||||
)
|
||||
|
||||
var regexMetadata = regexp.MustCompile(validMetadata)
|
||||
|
||||
type Metadata string
|
||||
|
||||
func SplitMetadata(m Metadata) (string, string, error) {
|
||||
if !regexMetadata.MatchString(string(m)) {
|
||||
return "", "", fmt.Errorf("invalid metadata: %s", m)
|
||||
}
|
||||
|
||||
match := regexMetadata.FindStringSubmatch(string(m))
|
||||
return match[1], match[2], nil
|
||||
}
|
Reference in New Issue
Block a user