This mostly works:
import "encoding/hex"
func isHexString(s string) bool {
_, err := hex.DecodeString(s)
return err == nil
}
However, we also may want to support odd length hex strings. Checking against hex.ErrLength doesn't work because this error precedes whether the string contains hex characters. I guess could manipulate string to contain the appropriate number of characters and apply both checks but it seems like there should be better way.