gofix run

This commit is contained in:
Alex Bramley 2011-07-18 09:14:58 +01:00
parent 83b482f8ce
commit 5027646478
2 changed files with 24 additions and 24 deletions

View File

@ -50,7 +50,7 @@ type Conn struct {
Timestamp func() *time.Time Timestamp func() *time.Time
// Enable debugging? Set format for timestamps on debug output. // Enable debugging? Set format for timestamps on debug output.
Debug bool Debug bool
TSFormat string 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, // It's unfortunate that tls.Dial doesn't allow a tls.Config arg,
// so we simply replicate it here with the correct Config. // so we simply replicate it here with the correct Config.
// http://codereview.appspot.com/2883041 // 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. // Passing nil config => certs are validated.
c := tls.Client(s, conn.SSLConfig) c := tls.Client(s, conn.SSLConfig)
if err = c.Handshake(); err == nil { if err = c.Handshake(); err == nil {
@ -133,7 +133,7 @@ func (conn *Conn) Connect(host string, pass ...string) os.Error {
if !hasPort(host) { if !hasPort(host) {
host += ":6667" host += ":6667"
} }
if s, err := net.Dial("tcp", "", host); err == nil { if s, err := net.Dial("tcp", host); err == nil {
conn.sock = s conn.sock = s
} else { } else {
return err return err

View File

@ -402,23 +402,23 @@ func (n *Nick) String() string {
func (cm *ChanMode) String() string { func (cm *ChanMode) String() string {
str := "+" str := "+"
a := make([]string, 2) a := make([]string, 2)
v := reflect.Indirect(reflect.NewValue(cm)).(*reflect.StructValue) v := reflect.Indirect(reflect.ValueOf(cm))
t := v.Type().(*reflect.StructType) t := v.Type()
for i := 0; i < v.NumField(); i++ { for i := 0; i < v.NumField(); i++ {
switch f := v.Field(i).(type) { switch f := v.Field(i); f.Kind() {
case *reflect.BoolValue: case reflect.Bool:
if f.Get() { if f.Bool() {
str += ChanModeToString[t.Field(i).Name] str += ChanModeToString[t.Field(i).Name]
} }
case *reflect.StringValue: case reflect.String:
if f.Get() != "" { if f.String() != "" {
str += ChanModeToString[t.Field(i).Name] str += ChanModeToString[t.Field(i).Name]
a[0] = f.Get() a[0] = f.String()
} }
case *reflect.IntValue: case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
if f.Get() != 0 { if f.Int() != 0 {
str += ChanModeToString[t.Field(i).Name] 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 // +iwx
func (nm *NickMode) String() string { func (nm *NickMode) String() string {
str := "+" str := "+"
v := reflect.Indirect(reflect.NewValue(nm)).(*reflect.StructValue) v := reflect.Indirect(reflect.ValueOf(nm))
t := v.Type().(*reflect.StructType) t := v.Type()
for i := 0; i < v.NumField(); i++ { 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! // only bools here at the mo!
case *reflect.BoolValue: case reflect.Bool:
if f.Get() { if f.Bool() {
str += NickModeToString[t.Field(i).Name] str += NickModeToString[t.Field(i).Name]
} }
} }
@ -458,13 +458,13 @@ func (nm *NickMode) String() string {
// +o // +o
func (p *ChanPrivs) String() string { func (p *ChanPrivs) String() string {
str := "+" str := "+"
v := reflect.Indirect(reflect.NewValue(p)).(*reflect.StructValue) v := reflect.Indirect(reflect.ValueOf(p))
t := v.Type().(*reflect.StructType) t := v.Type()
for i := 0; i < v.NumField(); i++ { 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! // only bools here at the mo too!
case *reflect.BoolValue: case reflect.Bool:
if f.Get() { if f.Bool() {
str += ChanPrivToString[t.Field(i).Name] str += ChanPrivToString[t.Field(i).Name]
} }
} }