diff --git a/client/connection.go b/client/connection.go index 3be02e4..a18a4e7 100644 --- a/client/connection.go +++ b/client/connection.go @@ -50,7 +50,7 @@ type Conn struct { Timestamp func() *time.Time // Enable debugging? Set format for timestamps on debug output. - Debug bool + Debug bool TSFormat string } @@ -117,7 +117,7 @@ func (conn *Conn) Connect(host string, pass ...string) os.Error { // It's unfortunate that tls.Dial doesn't allow a tls.Config arg, // so we simply replicate it here with the correct Config. // http://codereview.appspot.com/2883041 - if s, err := net.Dial("tcp", "", host); err == nil { + if s, err := net.Dial("tcp", host); err == nil { // Passing nil config => certs are validated. c := tls.Client(s, conn.SSLConfig) if err = c.Handshake(); err == nil { @@ -133,7 +133,7 @@ func (conn *Conn) Connect(host string, pass ...string) os.Error { if !hasPort(host) { host += ":6667" } - if s, err := net.Dial("tcp", "", host); err == nil { + if s, err := net.Dial("tcp", host); err == nil { conn.sock = s } else { return err diff --git a/client/nickchan.go b/client/nickchan.go index 87f1da7..fdf79b1 100644 --- a/client/nickchan.go +++ b/client/nickchan.go @@ -402,23 +402,23 @@ func (n *Nick) String() string { func (cm *ChanMode) String() string { str := "+" a := make([]string, 2) - v := reflect.Indirect(reflect.NewValue(cm)).(*reflect.StructValue) - t := v.Type().(*reflect.StructType) + v := reflect.Indirect(reflect.ValueOf(cm)) + t := v.Type() for i := 0; i < v.NumField(); i++ { - switch f := v.Field(i).(type) { - case *reflect.BoolValue: - if f.Get() { + switch f := v.Field(i); f.Kind() { + case reflect.Bool: + if f.Bool() { str += ChanModeToString[t.Field(i).Name] } - case *reflect.StringValue: - if f.Get() != "" { + case reflect.String: + if f.String() != "" { str += ChanModeToString[t.Field(i).Name] - a[0] = f.Get() + a[0] = f.String() } - case *reflect.IntValue: - if f.Get() != 0 { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if f.Int() != 0 { str += ChanModeToString[t.Field(i).Name] - a[1] = fmt.Sprintf("%d", f.Get()) + a[1] = fmt.Sprintf("%d", f.Int()) } } } @@ -437,13 +437,13 @@ func (cm *ChanMode) String() string { // +iwx func (nm *NickMode) String() string { str := "+" - v := reflect.Indirect(reflect.NewValue(nm)).(*reflect.StructValue) - t := v.Type().(*reflect.StructType) + v := reflect.Indirect(reflect.ValueOf(nm)) + t := v.Type() for i := 0; i < v.NumField(); i++ { - switch f := v.Field(i).(type) { + switch f := v.Field(i); f.Kind() { // only bools here at the mo! - case *reflect.BoolValue: - if f.Get() { + case reflect.Bool: + if f.Bool() { str += NickModeToString[t.Field(i).Name] } } @@ -458,13 +458,13 @@ func (nm *NickMode) String() string { // +o func (p *ChanPrivs) String() string { str := "+" - v := reflect.Indirect(reflect.NewValue(p)).(*reflect.StructValue) - t := v.Type().(*reflect.StructType) + v := reflect.Indirect(reflect.ValueOf(p)) + t := v.Type() for i := 0; i < v.NumField(); i++ { - switch f := v.Field(i).(type) { + switch f := v.Field(i); f.Kind() { // only bools here at the mo too! - case *reflect.BoolValue: - if f.Get() { + case reflect.Bool: + if f.Bool() { str += ChanPrivToString[t.Field(i).Name] } }