FAQ
Why “var value *int" value is nil, but the expression "nil == value" is
false

OS: Windows Seven 2003
Go: go version go1.0.2

----------------------------------------
package testValue

import (
"fmt"
"testing"
"strconv"
)

type Value interface {
String() string
}

type IntValue int

func (v *IntValue) String() string {
return strconv.Itoa(int(*v))
}

func NewIntValueFromString(s string) (*IntValue, error) {
return nil, fmt.Errorf("not implemented")
}

func TestValue(t *testing.T) {
var nv Value = nil
nv, _ = NewIntValueFromString("[int32]12a345")

if nil != nv {
t.Errorf("nv is %v, why it is notequals nil", nv)
}
}

--

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 12, '12 at 4:06a
activeSep 12, '12 at 6:32a
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase