Skip to content

JSON [line:108] string is not os.Error: missing method String #977

@gopherbot

Description

@gopherbot

by eshurmin:

What steps will reproduce the problem?
1. 8g -o json.8 json.go
2. 8l -o json json.8 
3. ./json

What is the expected output?

>>> Marshal
T: {341}
Marshal T: {"z":"341"}
>>> Unmarshal
panic: cannot set value obtained via unexported struct field [recovered]
    panic: interface conversion: string is not os.Error: missing method String

panic PC=0x95f2b8
runtime.panic+0xa9 /home/jpascal/go/src/pkg/runtime/proc.c:1012
    runtime.panic(0x0, 0x80866a0)
itab+0xd6 /home/jpascal/go/src/pkg/runtime/iface.c:125
    itab(0x80aab48, 0x9696c0, 0x8086698, 0x0)
ifaceE2I+0xa8 /home/jpascal/go/src/pkg/runtime/iface.c:445
    ifaceE2I(0x8086698, 0x809e91c, 0x0, 0x95c, 0x80a24ec, ...)
runtime.assertE2I+0x27 /home/jpascal/go/src/pkg/runtime/iface.c:453
    runtime.assertE2I(0x8086698, 0x809e91c, 0x947880, 0x95f394, 0x95c000, ...)
json._func_001+0x89 /home/jpascal/go/src/pkg/json/decode.go:108
    json._func_001(0x8086698, 0x809e91c, 0x947880, 0x0)
runtime.panic+0xe9 /home/jpascal/go/src/pkg/runtime/proc.c:994
    runtime.panic(0x95b2e0, 0x95b2d4)
reflect.*StringValue·Set+0x5f /home/jpascal/go/src/pkg/reflect/value.go:294
    reflect.*StringValue·Set(0x809e91c, 0x947880, 0x35)
json.*decodeState·literal+0x37a /home/jpascal/go/src/pkg/json/decode.go:553
    json.*decodeState·literal(0x95c160, 0x947878, 0x3)
json.*decodeState·value+0x1cc /home/jpascal/go/src/pkg/json/decode.go:232
    json.*decodeState·value(0x949b40, 0x95a5a0, 0x95c160)
json.*decodeState·object+0x4b7 /home/jpascal/go/src/pkg/json/decode.go:480
    json.*decodeState·object(0x949b40, 0x95a5a0, 0x95c160)
json.*decodeState·value+0x1ee /home/jpascal/go/src/pkg/json/decode.go:229
    json.*decodeState·value(0x949b40, 0x95a5d0, 0x95c180)
json.*decodeState·unmarshal+0x100 /home/jpascal/go/src/pkg/json/decode.go:119
    json.*decodeState·unmarshal(0x949b40, 0x95a5d0, 0x95c180, 0x95c190, 0x101, ...)
json.Unmarshal+0xa0 /home/jpascal/go/src/pkg/json/decode.go:61
    json.Unmarshal(0x949b40, 0x8095c04, 0x947800, 0x949b50, 0x0, ...)
main.main+0x343 /home/jpascal/Проекты/Наработки/JSON/json.go:34
    main.main()
mainstart+0xf /home/jpascal/go/src/pkg/runtime/386/asm.s:83
    mainstart()
goexit /home/jpascal/go/src/pkg/runtime/proc.c:145
    goexit()


What is your $GOOS?  $GOARCH?
GOOS=linux
GOARCH=386

Which revision are you using? 
b501df553a4b tip

I dont want recive panic.
I want recive os.Error only.

Attachments:

  1. json.go (559 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions