go - Managing errors in golang -
i'm coming ruby , looking @ go @ moment. start writing little bit of code check tls support given host. var tls_versions = map[uint16]string{ tls.versionssl30: "sslv3", tls.versiontls10: "tlsv1.0", tls.versiontls11: "tlsv1.1", tls.versiontls12: "tlsv1.2", } var refused_re = regexp.mustcompile(": connection refused") var nodns_re = regexp.mustcompile(": no such host") var versionnotsupported_re = regexp.mustcompile(": protocol version not supported") func checkversion(host string) (map[string]bool, error) { // {{ ret := map[string]bool{} version := tls.versionssl30; version <= tls.versiontls12; version++ { conn, err := tls.dial("tcp", host+":443", &tls.config{ minversion: uint16(version), }) if err != nil && (refused_re.matchstring(err.error()) == true || nodns_re.matchstring(err.error()) == true) { log.println(err) ...