This regexp can be used to validate domain names in Golang.
While it cannot enforce the 253 character limit (with optional trailing period not included)
that can be easily done with a len(domain) <= 253
check.
This can be used as-is in other languages, even with RE2 regex engine. Non-capturing groups are used.