Source File
identifier.go
Belonging Package
github.com/google/safehtml
package safehtml
import (
)
var startsWithAlphabetPattern = regexp.MustCompile(`^[a-zA-Z]`)
var onlyAlphanumericsOrHyphenPattern = regexp.MustCompile(`^[-_a-zA-Z0-9]*$`)
func ( stringConstant) Identifier {
if !startsWithAlphabetPattern.MatchString(string()) ||
!onlyAlphanumericsOrHyphenPattern.MatchString(string()) {
panic(fmt.Sprintf("invalid identifier %q", string()))
}
return Identifier{string()}
}
func ( stringConstant, string) Identifier {
:= string()
if !startsWithAlphabetPattern.MatchString(string()) ||
!onlyAlphanumericsOrHyphenPattern.MatchString(string()) {
panic(fmt.Sprintf("invalid prefix %q", string()))
}
if !onlyAlphanumericsOrHyphenPattern.MatchString() {
panic(fmt.Sprintf("value %q contains non-alphanumeric runes", ))
}
return Identifier{ + "-" + }
}
func ( Identifier) () string {
return .str
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |