Skip to content

Instantly share code, notes, and snippets.

@jawnsy
Created October 24, 2017 17:33
Show Gist options
  • Save jawnsy/613405bd42eb7f8ffaa6bdde4c372048 to your computer and use it in GitHub Desktop.
Save jawnsy/613405bd42eb7f8ffaa6bdde4c372048 to your computer and use it in GitHub Desktop.
Checking vs not checking type assertion
package main
import "fmt"
type Context struct {
}
func main() {
a := &Context{}
var b interface{} = a
value := typeAssert(b)
fmt.Printf("%#v\n", value)
value = typeAssert(nil)
fmt.Printf("%#v\n", value)
}
func typeAssert(value interface{}) *Context {
if ctx, ok := value.(*Context); ok {
return ctx
}
return nil
}
"".main STEXT size=271 args=0x0 locals=0x68
0x0000 00000 (assert-check.go:8) TEXT "".main(SB), $104-0
0x0000 00000 (assert-check.go:8) MOVQ (TLS), CX
0x0009 00009 (assert-check.go:8) CMPQ SP, 16(CX)
0x000d 00013 (assert-check.go:8) JLS 261
0x0013 00019 (assert-check.go:8) SUBQ $104, SP
0x0017 00023 (assert-check.go:8) MOVQ BP, 96(SP)
0x001c 00028 (assert-check.go:8) LEAQ 96(SP), BP
0x0021 00033 (assert-check.go:8) FUNCDATA $0, gclocals·7d2d5fca80364273fb07d5820a76fef4(SB)
0x0021 00033 (assert-check.go:8) FUNCDATA $1, gclocals·dc990f0ce5208716c4d33a75f4225a61(SB)
0x0021 00033 (assert-check.go:8) LEAQ type."".Context(SB), AX
0x0028 00040 (assert-check.go:9) MOVQ AX, (SP)
0x002c 00044 (assert-check.go:9) PCDATA $0, $0
0x002c 00044 (assert-check.go:9) CALL runtime.newobject(SB)
0x0031 00049 (assert-check.go:9) MOVQ 8(SP), AX
0x0036 00054 (assert-check.go:13) MOVQ $0, ""..autotmp_14+80(SP)
0x003f 00063 (assert-check.go:13) MOVQ $0, ""..autotmp_14+88(SP)
0x0048 00072 (assert-check.go:13) LEAQ type.*"".Context(SB), CX
0x004f 00079 (assert-check.go:13) MOVQ CX, ""..autotmp_14+80(SP)
0x0054 00084 (assert-check.go:13) MOVQ AX, ""..autotmp_14+88(SP)
0x0059 00089 (assert-check.go:13) LEAQ go.string."%#v\n"(SB), AX
0x0060 00096 (assert-check.go:13) MOVQ AX, (SP)
0x0064 00100 (assert-check.go:13) MOVQ $4, 8(SP)
0x006d 00109 (assert-check.go:13) LEAQ ""..autotmp_14+80(SP), DX
0x0072 00114 (assert-check.go:13) MOVQ DX, 16(SP)
0x0077 00119 (assert-check.go:13) MOVQ $1, 24(SP)
0x0080 00128 (assert-check.go:13) MOVQ $1, 32(SP)
0x0089 00137 (assert-check.go:13) PCDATA $0, $1
0x0089 00137 (assert-check.go:13) CALL fmt.Printf(SB)
0x008e 00142 (assert-check.go:13) LEAQ type.*"".Context(SB), AX
0x0095 00149 (assert-check.go:15) TESTQ AX, AX
0x0098 00152 (assert-check.go:15) JNE 254
0x009a 00154 (assert-check.go:15) MOVL $0, CX
0x009f 00159 (assert-check.go:15) JEQ 163
0x00a1 00161 (assert-check.go:15) MOVL $0, CX
0x00a3 00163 (assert-check.go:16) MOVQ $0, ""..autotmp_18+64(SP)
0x00ac 00172 (assert-check.go:16) MOVQ $0, ""..autotmp_18+72(SP)
0x00b5 00181 (assert-check.go:16) MOVQ AX, ""..autotmp_18+64(SP)
0x00ba 00186 (assert-check.go:16) MOVQ CX, ""..autotmp_18+72(SP)
0x00bf 00191 (assert-check.go:16) LEAQ go.string."%#v\n"(SB), AX
0x00c6 00198 (assert-check.go:16) MOVQ AX, (SP)
0x00ca 00202 (assert-check.go:16) MOVQ $4, 8(SP)
0x00d3 00211 (assert-check.go:16) LEAQ ""..autotmp_18+64(SP), AX
0x00d8 00216 (assert-check.go:16) MOVQ AX, 16(SP)
0x00dd 00221 (assert-check.go:16) MOVQ $1, 24(SP)
0x00e6 00230 (assert-check.go:16) MOVQ $1, 32(SP)
0x00ef 00239 (assert-check.go:16) PCDATA $0, $2
0x00ef 00239 (assert-check.go:16) CALL fmt.Printf(SB)
0x00f4 00244 (assert-check.go:17) MOVQ 96(SP), BP
0x00f9 00249 (assert-check.go:17) ADDQ $104, SP
0x00fd 00253 (assert-check.go:17) RET
0x00fe 00254 (assert-check.go:17) MOVL $0, CX
0x0103 00259 (assert-check.go:15) JMP 159
0x0105 00261 (assert-check.go:15) NOP
0x0105 00261 (assert-check.go:8) PCDATA $0, $-1
0x0105 00261 (assert-check.go:8) CALL runtime.morestack_noctxt(SB)
0x010a 00266 (assert-check.go:8) JMP 0
0x0000 64 48 8b 0c 25 00 00 00 00 48 3b 61 10 0f 86 f2 dH..%....H;a....
0x0010 00 00 00 48 83 ec 68 48 89 6c 24 60 48 8d 6c 24 ...H..hH.l$`H.l$
0x0020 60 48 8d 05 00 00 00 00 48 89 04 24 e8 00 00 00 `H......H..$....
0x0030 00 48 8b 44 24 08 48 c7 44 24 50 00 00 00 00 48 .H.D$.H.D$P....H
0x0040 c7 44 24 58 00 00 00 00 48 8d 0d 00 00 00 00 48 .D$X....H......H
0x0050 89 4c 24 50 48 89 44 24 58 48 8d 05 00 00 00 00 .L$PH.D$XH......
0x0060 48 89 04 24 48 c7 44 24 08 04 00 00 00 48 8d 54 H..$H.D$.....H.T
0x0070 24 50 48 89 54 24 10 48 c7 44 24 18 01 00 00 00 $PH.T$.H.D$.....
0x0080 48 c7 44 24 20 01 00 00 00 e8 00 00 00 00 48 8d H.D$ .........H.
0x0090 05 00 00 00 00 48 85 c0 75 64 b9 00 00 00 00 74 .....H..ud.....t
0x00a0 02 31 c9 48 c7 44 24 40 00 00 00 00 48 c7 44 24 [email protected]$
0x00b0 48 00 00 00 00 48 89 44 24 40 48 89 4c 24 48 48 [email protected]$HH
0x00c0 8d 05 00 00 00 00 48 89 04 24 48 c7 44 24 08 04 ......H..$H.D$..
0x00d0 00 00 00 48 8d 44 24 40 48 89 44 24 10 48 c7 44 [email protected]$.H.D
0x00e0 24 18 01 00 00 00 48 c7 44 24 20 01 00 00 00 e8 $.....H.D$ .....
0x00f0 00 00 00 00 48 8b 6c 24 60 48 83 c4 68 c3 b9 00 ....H.l$`H..h...
0x0100 00 00 00 eb 9a e8 00 00 00 00 e9 f1 fe ff ff ...............
rel 5+4 t=16 TLS+0
rel 36+4 t=15 type."".Context+0
rel 45+4 t=8 runtime.newobject+0
rel 75+4 t=15 type.*"".Context+0
rel 92+4 t=15 go.string."%#v\n"+0
rel 138+4 t=8 fmt.Printf+0
rel 145+4 t=15 type.*"".Context+0
rel 194+4 t=15 go.string."%#v\n"+0
rel 240+4 t=8 fmt.Printf+0
rel 262+4 t=8 runtime.morestack_noctxt+0
"".typeAssert STEXT nosplit size=47 args=0x18 locals=0x0
0x0000 00000 (assert-check.go:19) TEXT "".typeAssert(SB), NOSPLIT, $0-24
0x0000 00000 (assert-check.go:19) FUNCDATA $0, gclocals·8f9cec06d1ae35cc9900c511c5e4bdab(SB)
0x0000 00000 (assert-check.go:19) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (assert-check.go:19) MOVQ "".value+8(SP), AX
0x0005 00005 (assert-check.go:19) LEAQ type.*"".Context(SB), CX
0x000c 00012 (assert-check.go:20) CMPQ AX, CX
0x000f 00015 (assert-check.go:20) JNE 40
0x0011 00017 (assert-check.go:20) MOVQ "".value+16(SP), AX
0x0016 00022 (assert-check.go:20) JNE 30
0x0018 00024 (assert-check.go:21) MOVQ AX, "".~r1+24(SP)
0x001d 00029 (assert-check.go:21) RET
0x001e 00030 (assert-check.go:23) MOVQ $0, "".~r1+24(SP)
0x0027 00039 (assert-check.go:23) RET
0x0028 00040 (assert-check.go:23) MOVL $0, AX
0x002d 00045 (assert-check.go:20) JMP 22
0x0000 48 8b 44 24 08 48 8d 0d 00 00 00 00 48 39 c8 75 H.D$.H......H9.u
0x0010 17 48 8b 44 24 10 75 06 48 89 44 24 18 c3 48 c7 .H.D$.u.H.D$..H.
0x0020 44 24 18 00 00 00 00 c3 b8 00 00 00 00 eb e7 D$.............
rel 8+4 t=15 type.*"".Context+0
"".init STEXT size=91 args=0x0 locals=0x8
0x0000 00000 (<autogenerated>:1) TEXT "".init(SB), $8-0
0x0000 00000 (<autogenerated>:1) MOVQ (TLS), CX
0x0009 00009 (<autogenerated>:1) CMPQ SP, 16(CX)
0x000d 00013 (<autogenerated>:1) JLS 84
0x000f 00015 (<autogenerated>:1) SUBQ $8, SP
0x0013 00019 (<autogenerated>:1) MOVQ BP, (SP)
0x0017 00023 (<autogenerated>:1) LEAQ (SP), BP
0x001b 00027 (<autogenerated>:1) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x001b 00027 (<autogenerated>:1) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x001b 00027 (<autogenerated>:1) MOVBLZX "".initdone·(SB), AX
0x0022 00034 (<autogenerated>:1) CMPB AL, $1
0x0024 00036 (<autogenerated>:1) JLS 47
0x0026 00038 (<autogenerated>:1) MOVQ (SP), BP
0x002a 00042 (<autogenerated>:1) ADDQ $8, SP
0x002e 00046 (<autogenerated>:1) RET
0x002f 00047 (<autogenerated>:1) JNE 56
0x0031 00049 (<autogenerated>:1) PCDATA $0, $0
0x0031 00049 (<autogenerated>:1) CALL runtime.throwinit(SB)
0x0036 00054 (<autogenerated>:1) UNDEF
0x0038 00056 (<autogenerated>:1) MOVB $1, "".initdone·(SB)
0x003f 00063 (<autogenerated>:1) PCDATA $0, $0
0x003f 00063 (<autogenerated>:1) CALL fmt.init(SB)
0x0044 00068 (<autogenerated>:1) MOVB $2, "".initdone·(SB)
0x004b 00075 (<autogenerated>:1) MOVQ (SP), BP
0x004f 00079 (<autogenerated>:1) ADDQ $8, SP
0x0053 00083 (<autogenerated>:1) RET
0x0054 00084 (<autogenerated>:1) NOP
0x0054 00084 (<autogenerated>:1) PCDATA $0, $-1
0x0054 00084 (<autogenerated>:1) CALL runtime.morestack_noctxt(SB)
0x0059 00089 (<autogenerated>:1) JMP 0
0x0000 64 48 8b 0c 25 00 00 00 00 48 3b 61 10 76 45 48 dH..%....H;a.vEH
0x0010 83 ec 08 48 89 2c 24 48 8d 2c 24 0f b6 05 00 00 ...H.,$H.,$.....
0x0020 00 00 3c 01 76 09 48 8b 2c 24 48 83 c4 08 c3 75 ..<.v.H.,$H....u
0x0030 07 e8 00 00 00 00 0f 0b c6 05 00 00 00 00 01 e8 ................
0x0040 00 00 00 00 c6 05 00 00 00 00 02 48 8b 2c 24 48 ...........H.,$H
0x0050 83 c4 08 c3 e8 00 00 00 00 eb a5 ...........
rel 5+4 t=16 TLS+0
rel 30+4 t=15 "".initdone·+0
rel 50+4 t=8 runtime.throwinit+0
rel 58+4 t=15 "".initdone·+-1
rel 64+4 t=8 fmt.init+0
rel 70+4 t=15 "".initdone·+-1
rel 85+4 t=8 runtime.morestack_noctxt+0
go.string."%#v\n" SRODATA dupok size=4
0x0000 25 23 76 0a %#v.
go.info."".main SDWARFINFO size=29
0x0000 02 22 22 2e 6d 61 69 6e 00 00 00 00 00 00 00 00 ."".main........
0x0010 00 00 00 00 00 00 00 00 00 01 9c 01 00 .............
rel 9+8 t=1 "".main+0
rel 17+8 t=1 "".main+271
go.range."".main SDWARFRANGE size=0
go.info."".typeAssert SDWARFINFO size=62
0x0000 02 22 22 2e 74 79 70 65 41 73 73 65 72 74 00 00 ."".typeAssert..
0x0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................
0x0020 9c 01 05 76 61 6c 75 65 00 01 9c 00 00 00 00 05 ...value........
0x0030 7e 72 31 00 04 9c 11 10 22 00 00 00 00 00 ~r1.....".....
rel 15+8 t=1 "".typeAssert+0
rel 23+8 t=1 "".typeAssert+47
rel 43+4 t=28 go.info.interface {}+0
rel 57+4 t=28 go.info.*"".Context+0
go.range."".typeAssert SDWARFRANGE size=0
go.info."".init SDWARFINFO size=29
0x0000 02 22 22 2e 69 6e 69 74 00 00 00 00 00 00 00 00 ."".init........
0x0010 00 00 00 00 00 00 00 00 00 01 9c 01 00 .............
rel 9+8 t=1 "".init+0
rel 17+8 t=1 "".init+91
go.range."".init SDWARFRANGE size=0
"".initdone· SNOPTRBSS size=1
runtime.gcbits.01 SRODATA dupok size=1
0x0000 01 .
type..namedata.*main.Context. SRODATA dupok size=16
0x0000 01 00 0d 2a 6d 61 69 6e 2e 43 6f 6e 74 65 78 74 ...*main.Context
type.*"".Context SRODATA size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 e5 6e 30 7c 00 08 08 36 00 00 00 00 00 00 00 00 .n0|...6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*main.Context.+0
rel 48+8 t=1 type."".Context+0
runtime.gcbits. SRODATA dupok size=0
type."".Context SRODATA size=96
0x0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0010 07 4d 37 d0 07 01 01 99 00 00 00 00 00 00 00 00 .M7.............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0050 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
rel 24+8 t=1 runtime.algarray+16
rel 32+8 t=1 runtime.gcbits.+0
rel 40+4 t=5 type..namedata.*main.Context.+0
rel 44+4 t=5 type.*"".Context+0
rel 48+8 t=1 type..importpath."".+0
rel 56+8 t=1 type."".Context+96
rel 80+4 t=5 type..importpath."".+0
type..namedata.*interface {}- SRODATA dupok size=16
0x0000 00 00 0d 2a 69 6e 74 65 72 66 61 63 65 20 7b 7d ...*interface {}
type.*interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 4f 0f 96 9d 00 08 08 36 00 00 00 00 00 00 00 00 O......6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*interface {}-+0
rel 48+8 t=1 type.interface {}+0
runtime.gcbits.03 SRODATA dupok size=1
0x0000 03 .
type.interface {} SRODATA dupok size=80
0x0000 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
0x0010 e7 57 a0 18 02 08 08 14 00 00 00 00 00 00 00 00 .W..............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
rel 24+8 t=1 runtime.algarray+144
rel 32+8 t=1 runtime.gcbits.03+0
rel 40+4 t=5 type..namedata.*interface {}-+0
rel 44+4 t=6 type.*interface {}+0
rel 56+8 t=1 type.interface {}+80
type..namedata.*[]interface {}- SRODATA dupok size=18
0x0000 00 00 0f 2a 5b 5d 69 6e 74 65 72 66 61 63 65 20 ...*[]interface
0x0010 7b 7d {}
type.*[]interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 f3 04 9a e7 00 08 08 36 00 00 00 00 00 00 00 00 .......6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[]interface {}-+0
rel 48+8 t=1 type.[]interface {}+0
type.[]interface {} SRODATA dupok size=56
0x0000 18 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 70 93 ea 2f 02 08 08 17 00 00 00 00 00 00 00 00 p../............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+0
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[]interface {}-+0
rel 44+4 t=6 type.*[]interface {}+0
rel 48+8 t=1 type.interface {}+0
type..namedata.*[1]interface {}- SRODATA dupok size=19
0x0000 00 00 10 2a 5b 31 5d 69 6e 74 65 72 66 61 63 65 ...*[1]interface
0x0010 20 7b 7d {}
type.*[1]interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 bf 03 a8 35 00 08 08 36 00 00 00 00 00 00 00 00 ...5...6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[1]interface {}-+0
rel 48+8 t=1 type.[1]interface {}+0
type.[1]interface {} SRODATA dupok size=72
0x0000 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
0x0010 50 91 5b fa 02 08 08 11 00 00 00 00 00 00 00 00 P.[.............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 01 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+144
rel 32+8 t=1 runtime.gcbits.03+0
rel 40+4 t=5 type..namedata.*[1]interface {}-+0
rel 44+4 t=6 type.*[1]interface {}+0
rel 48+8 t=1 type.interface {}+0
rel 56+8 t=1 type.[]interface {}+0
type..importpath.fmt. SRODATA dupok size=6
0x0000 00 00 03 66 6d 74 ...fmt
gclocals·7d2d5fca80364273fb07d5820a76fef4 SRODATA dupok size=8
0x0000 03 00 00 00 00 00 00 00 ........
gclocals·dc990f0ce5208716c4d33a75f4225a61 SRODATA dupok size=11
0x0000 03 00 00 00 04 00 00 00 00 0c 03 ...........
gclocals·8f9cec06d1ae35cc9900c511c5e4bdab SRODATA dupok size=9
0x0000 01 00 00 00 03 00 00 00 03 .........
gclocals·33cdeccccebe80329f1fdbee7f5874cb SRODATA dupok size=8
0x0000 01 00 00 00 00 00 00 00 ........
package main
import "fmt"
type Context struct {
}
func main() {
a := &Context{}
var b interface{} = a
value := typeAssert(b)
fmt.Printf("%#v\n", value)
value = typeAssert(nil)
fmt.Printf("%#v\n", value)
}
func typeAssert(value interface{}) *Context {
ctx, _ := value.(*Context)
return ctx
}
"".main STEXT size=261 args=0x0 locals=0x68
0x0000 00000 (assert-nocheck.go:8) TEXT "".main(SB), $104-0
0x0000 00000 (assert-nocheck.go:8) MOVQ (TLS), CX
0x0009 00009 (assert-nocheck.go:8) CMPQ SP, 16(CX)
0x000d 00013 (assert-nocheck.go:8) JLS 251
0x0013 00019 (assert-nocheck.go:8) SUBQ $104, SP
0x0017 00023 (assert-nocheck.go:8) MOVQ BP, 96(SP)
0x001c 00028 (assert-nocheck.go:8) LEAQ 96(SP), BP
0x0021 00033 (assert-nocheck.go:8) FUNCDATA $0, gclocals·7d2d5fca80364273fb07d5820a76fef4(SB)
0x0021 00033 (assert-nocheck.go:8) FUNCDATA $1, gclocals·dc990f0ce5208716c4d33a75f4225a61(SB)
0x0021 00033 (assert-nocheck.go:8) LEAQ type."".Context(SB), AX
0x0028 00040 (assert-nocheck.go:9) MOVQ AX, (SP)
0x002c 00044 (assert-nocheck.go:9) PCDATA $0, $0
0x002c 00044 (assert-nocheck.go:9) CALL runtime.newobject(SB)
0x0031 00049 (assert-nocheck.go:9) MOVQ 8(SP), AX
0x0036 00054 (assert-nocheck.go:13) MOVQ $0, ""..autotmp_11+80(SP)
0x003f 00063 (assert-nocheck.go:13) MOVQ $0, ""..autotmp_11+88(SP)
0x0048 00072 (assert-nocheck.go:13) LEAQ type.*"".Context(SB), CX
0x004f 00079 (assert-nocheck.go:13) MOVQ CX, ""..autotmp_11+80(SP)
0x0054 00084 (assert-nocheck.go:13) MOVQ AX, ""..autotmp_11+88(SP)
0x0059 00089 (assert-nocheck.go:13) LEAQ go.string."%#v\n"(SB), AX
0x0060 00096 (assert-nocheck.go:13) MOVQ AX, (SP)
0x0064 00100 (assert-nocheck.go:13) MOVQ $4, 8(SP)
0x006d 00109 (assert-nocheck.go:13) LEAQ ""..autotmp_11+80(SP), DX
0x0072 00114 (assert-nocheck.go:13) MOVQ DX, 16(SP)
0x0077 00119 (assert-nocheck.go:13) MOVQ $1, 24(SP)
0x0080 00128 (assert-nocheck.go:13) MOVQ $1, 32(SP)
0x0089 00137 (assert-nocheck.go:13) PCDATA $0, $1
0x0089 00137 (assert-nocheck.go:13) CALL fmt.Printf(SB)
0x008e 00142 (assert-nocheck.go:13) LEAQ type.*"".Context(SB), AX
0x0095 00149 (assert-nocheck.go:15) TESTQ AX, AX
0x0098 00152 (assert-nocheck.go:15) JNE 247
0x009a 00154 (assert-nocheck.go:15) MOVL $0, CX
0x009c 00156 (assert-nocheck.go:16) MOVQ $0, ""..autotmp_14+64(SP)
0x00a5 00165 (assert-nocheck.go:16) MOVQ $0, ""..autotmp_14+72(SP)
0x00ae 00174 (assert-nocheck.go:16) MOVQ AX, ""..autotmp_14+64(SP)
0x00b3 00179 (assert-nocheck.go:16) MOVQ CX, ""..autotmp_14+72(SP)
0x00b8 00184 (assert-nocheck.go:16) LEAQ go.string."%#v\n"(SB), AX
0x00bf 00191 (assert-nocheck.go:16) MOVQ AX, (SP)
0x00c3 00195 (assert-nocheck.go:16) MOVQ $4, 8(SP)
0x00cc 00204 (assert-nocheck.go:16) LEAQ ""..autotmp_14+64(SP), AX
0x00d1 00209 (assert-nocheck.go:16) MOVQ AX, 16(SP)
0x00d6 00214 (assert-nocheck.go:16) MOVQ $1, 24(SP)
0x00df 00223 (assert-nocheck.go:16) MOVQ $1, 32(SP)
0x00e8 00232 (assert-nocheck.go:16) PCDATA $0, $2
0x00e8 00232 (assert-nocheck.go:16) CALL fmt.Printf(SB)
0x00ed 00237 (assert-nocheck.go:17) MOVQ 96(SP), BP
0x00f2 00242 (assert-nocheck.go:17) ADDQ $104, SP
0x00f6 00246 (assert-nocheck.go:17) RET
0x00f7 00247 (assert-nocheck.go:17) MOVL $0, CX
0x00f9 00249 (assert-nocheck.go:15) JMP 156
0x00fb 00251 (assert-nocheck.go:15) NOP
0x00fb 00251 (assert-nocheck.go:8) PCDATA $0, $-1
0x00fb 00251 (assert-nocheck.go:8) CALL runtime.morestack_noctxt(SB)
0x0100 00256 (assert-nocheck.go:8) JMP 0
0x0000 64 48 8b 0c 25 00 00 00 00 48 3b 61 10 0f 86 e8 dH..%....H;a....
0x0010 00 00 00 48 83 ec 68 48 89 6c 24 60 48 8d 6c 24 ...H..hH.l$`H.l$
0x0020 60 48 8d 05 00 00 00 00 48 89 04 24 e8 00 00 00 `H......H..$....
0x0030 00 48 8b 44 24 08 48 c7 44 24 50 00 00 00 00 48 .H.D$.H.D$P....H
0x0040 c7 44 24 58 00 00 00 00 48 8d 0d 00 00 00 00 48 .D$X....H......H
0x0050 89 4c 24 50 48 89 44 24 58 48 8d 05 00 00 00 00 .L$PH.D$XH......
0x0060 48 89 04 24 48 c7 44 24 08 04 00 00 00 48 8d 54 H..$H.D$.....H.T
0x0070 24 50 48 89 54 24 10 48 c7 44 24 18 01 00 00 00 $PH.T$.H.D$.....
0x0080 48 c7 44 24 20 01 00 00 00 e8 00 00 00 00 48 8d H.D$ .........H.
0x0090 05 00 00 00 00 48 85 c0 75 5d 31 c9 48 c7 44 24 .....H..u]1.H.D$
0x00a0 40 00 00 00 00 48 c7 44 24 48 00 00 00 00 48 89 @....H.D$H....H.
0x00b0 44 24 40 48 89 4c 24 48 48 8d 05 00 00 00 00 48 [email protected]$HH......H
0x00c0 89 04 24 48 c7 44 24 08 04 00 00 00 48 8d 44 24 ..$H.D$.....H.D$
0x00d0 40 48 89 44 24 10 48 c7 44 24 18 01 00 00 00 48 @H.D$.H.D$.....H
0x00e0 c7 44 24 20 01 00 00 00 e8 00 00 00 00 48 8b 6c .D$ .........H.l
0x00f0 24 60 48 83 c4 68 c3 31 c9 eb a1 e8 00 00 00 00 $`H..h.1........
0x0100 e9 fb fe ff ff .....
rel 5+4 t=16 TLS+0
rel 36+4 t=15 type."".Context+0
rel 45+4 t=8 runtime.newobject+0
rel 75+4 t=15 type.*"".Context+0
rel 92+4 t=15 go.string."%#v\n"+0
rel 138+4 t=8 fmt.Printf+0
rel 145+4 t=15 type.*"".Context+0
rel 187+4 t=15 go.string."%#v\n"+0
rel 233+4 t=8 fmt.Printf+0
rel 252+4 t=8 runtime.morestack_noctxt+0
"".typeAssert STEXT nosplit size=32 args=0x18 locals=0x0
0x0000 00000 (assert-nocheck.go:19) TEXT "".typeAssert(SB), NOSPLIT, $0-24
0x0000 00000 (assert-nocheck.go:19) FUNCDATA $0, gclocals·8f9cec06d1ae35cc9900c511c5e4bdab(SB)
0x0000 00000 (assert-nocheck.go:19) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (assert-nocheck.go:19) MOVQ "".value+8(SP), AX
0x0005 00005 (assert-nocheck.go:19) LEAQ type.*"".Context(SB), CX
0x000c 00012 (assert-nocheck.go:20) CMPQ AX, CX
0x000f 00015 (assert-nocheck.go:20) JNE 28
0x0011 00017 (assert-nocheck.go:20) MOVQ "".value+16(SP), AX
0x0016 00022 (assert-nocheck.go:21) MOVQ AX, "".~r1+24(SP)
0x001b 00027 (assert-nocheck.go:21) RET
0x001c 00028 (assert-nocheck.go:21) MOVL $0, AX
0x001e 00030 (assert-nocheck.go:20) JMP 22
0x0000 48 8b 44 24 08 48 8d 0d 00 00 00 00 48 39 c8 75 H.D$.H......H9.u
0x0010 0b 48 8b 44 24 10 48 89 44 24 18 c3 31 c0 eb f6 .H.D$.H.D$..1...
rel 8+4 t=15 type.*"".Context+0
"".init STEXT size=91 args=0x0 locals=0x8
0x0000 00000 (<autogenerated>:1) TEXT "".init(SB), $8-0
0x0000 00000 (<autogenerated>:1) MOVQ (TLS), CX
0x0009 00009 (<autogenerated>:1) CMPQ SP, 16(CX)
0x000d 00013 (<autogenerated>:1) JLS 84
0x000f 00015 (<autogenerated>:1) SUBQ $8, SP
0x0013 00019 (<autogenerated>:1) MOVQ BP, (SP)
0x0017 00023 (<autogenerated>:1) LEAQ (SP), BP
0x001b 00027 (<autogenerated>:1) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x001b 00027 (<autogenerated>:1) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x001b 00027 (<autogenerated>:1) MOVBLZX "".initdone·(SB), AX
0x0022 00034 (<autogenerated>:1) CMPB AL, $1
0x0024 00036 (<autogenerated>:1) JLS 47
0x0026 00038 (<autogenerated>:1) MOVQ (SP), BP
0x002a 00042 (<autogenerated>:1) ADDQ $8, SP
0x002e 00046 (<autogenerated>:1) RET
0x002f 00047 (<autogenerated>:1) JNE 56
0x0031 00049 (<autogenerated>:1) PCDATA $0, $0
0x0031 00049 (<autogenerated>:1) CALL runtime.throwinit(SB)
0x0036 00054 (<autogenerated>:1) UNDEF
0x0038 00056 (<autogenerated>:1) MOVB $1, "".initdone·(SB)
0x003f 00063 (<autogenerated>:1) PCDATA $0, $0
0x003f 00063 (<autogenerated>:1) CALL fmt.init(SB)
0x0044 00068 (<autogenerated>:1) MOVB $2, "".initdone·(SB)
0x004b 00075 (<autogenerated>:1) MOVQ (SP), BP
0x004f 00079 (<autogenerated>:1) ADDQ $8, SP
0x0053 00083 (<autogenerated>:1) RET
0x0054 00084 (<autogenerated>:1) NOP
0x0054 00084 (<autogenerated>:1) PCDATA $0, $-1
0x0054 00084 (<autogenerated>:1) CALL runtime.morestack_noctxt(SB)
0x0059 00089 (<autogenerated>:1) JMP 0
0x0000 64 48 8b 0c 25 00 00 00 00 48 3b 61 10 76 45 48 dH..%....H;a.vEH
0x0010 83 ec 08 48 89 2c 24 48 8d 2c 24 0f b6 05 00 00 ...H.,$H.,$.....
0x0020 00 00 3c 01 76 09 48 8b 2c 24 48 83 c4 08 c3 75 ..<.v.H.,$H....u
0x0030 07 e8 00 00 00 00 0f 0b c6 05 00 00 00 00 01 e8 ................
0x0040 00 00 00 00 c6 05 00 00 00 00 02 48 8b 2c 24 48 ...........H.,$H
0x0050 83 c4 08 c3 e8 00 00 00 00 eb a5 ...........
rel 5+4 t=16 TLS+0
rel 30+4 t=15 "".initdone·+0
rel 50+4 t=8 runtime.throwinit+0
rel 58+4 t=15 "".initdone·+-1
rel 64+4 t=8 fmt.init+0
rel 70+4 t=15 "".initdone·+-1
rel 85+4 t=8 runtime.morestack_noctxt+0
go.string."%#v\n" SRODATA dupok size=4
0x0000 25 23 76 0a %#v.
go.info."".main SDWARFINFO size=29
0x0000 02 22 22 2e 6d 61 69 6e 00 00 00 00 00 00 00 00 ."".main........
0x0010 00 00 00 00 00 00 00 00 00 01 9c 01 00 .............
rel 9+8 t=1 "".main+0
rel 17+8 t=1 "".main+261
go.range."".main SDWARFRANGE size=0
go.info."".typeAssert SDWARFINFO size=62
0x0000 02 22 22 2e 74 79 70 65 41 73 73 65 72 74 00 00 ."".typeAssert..
0x0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................
0x0020 9c 01 05 76 61 6c 75 65 00 01 9c 00 00 00 00 05 ...value........
0x0030 7e 72 31 00 04 9c 11 10 22 00 00 00 00 00 ~r1.....".....
rel 15+8 t=1 "".typeAssert+0
rel 23+8 t=1 "".typeAssert+32
rel 43+4 t=28 go.info.interface {}+0
rel 57+4 t=28 go.info.*"".Context+0
go.range."".typeAssert SDWARFRANGE size=0
go.info."".init SDWARFINFO size=29
0x0000 02 22 22 2e 69 6e 69 74 00 00 00 00 00 00 00 00 ."".init........
0x0010 00 00 00 00 00 00 00 00 00 01 9c 01 00 .............
rel 9+8 t=1 "".init+0
rel 17+8 t=1 "".init+91
go.range."".init SDWARFRANGE size=0
"".initdone· SNOPTRBSS size=1
runtime.gcbits.01 SRODATA dupok size=1
0x0000 01 .
type..namedata.*main.Context. SRODATA dupok size=16
0x0000 01 00 0d 2a 6d 61 69 6e 2e 43 6f 6e 74 65 78 74 ...*main.Context
type.*"".Context SRODATA size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 e5 6e 30 7c 00 08 08 36 00 00 00 00 00 00 00 00 .n0|...6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*main.Context.+0
rel 48+8 t=1 type."".Context+0
runtime.gcbits. SRODATA dupok size=0
type."".Context SRODATA size=96
0x0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0010 07 4d 37 d0 07 01 01 99 00 00 00 00 00 00 00 00 .M7.............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0050 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
rel 24+8 t=1 runtime.algarray+16
rel 32+8 t=1 runtime.gcbits.+0
rel 40+4 t=5 type..namedata.*main.Context.+0
rel 44+4 t=5 type.*"".Context+0
rel 48+8 t=1 type..importpath."".+0
rel 56+8 t=1 type."".Context+96
rel 80+4 t=5 type..importpath."".+0
type..namedata.*interface {}- SRODATA dupok size=16
0x0000 00 00 0d 2a 69 6e 74 65 72 66 61 63 65 20 7b 7d ...*interface {}
type.*interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 4f 0f 96 9d 00 08 08 36 00 00 00 00 00 00 00 00 O......6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*interface {}-+0
rel 48+8 t=1 type.interface {}+0
runtime.gcbits.03 SRODATA dupok size=1
0x0000 03 .
type.interface {} SRODATA dupok size=80
0x0000 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
0x0010 e7 57 a0 18 02 08 08 14 00 00 00 00 00 00 00 00 .W..............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
rel 24+8 t=1 runtime.algarray+144
rel 32+8 t=1 runtime.gcbits.03+0
rel 40+4 t=5 type..namedata.*interface {}-+0
rel 44+4 t=6 type.*interface {}+0
rel 56+8 t=1 type.interface {}+80
type..namedata.*[]interface {}- SRODATA dupok size=18
0x0000 00 00 0f 2a 5b 5d 69 6e 74 65 72 66 61 63 65 20 ...*[]interface
0x0010 7b 7d {}
type.*[]interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 f3 04 9a e7 00 08 08 36 00 00 00 00 00 00 00 00 .......6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[]interface {}-+0
rel 48+8 t=1 type.[]interface {}+0
type.[]interface {} SRODATA dupok size=56
0x0000 18 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 70 93 ea 2f 02 08 08 17 00 00 00 00 00 00 00 00 p../............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+0
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[]interface {}-+0
rel 44+4 t=6 type.*[]interface {}+0
rel 48+8 t=1 type.interface {}+0
type..namedata.*[1]interface {}- SRODATA dupok size=19
0x0000 00 00 10 2a 5b 31 5d 69 6e 74 65 72 66 61 63 65 ...*[1]interface
0x0010 20 7b 7d {}
type.*[1]interface {} SRODATA dupok size=56
0x0000 08 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 ................
0x0010 bf 03 a8 35 00 08 08 36 00 00 00 00 00 00 00 00 ...5...6........
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+80
rel 32+8 t=1 runtime.gcbits.01+0
rel 40+4 t=5 type..namedata.*[1]interface {}-+0
rel 48+8 t=1 type.[1]interface {}+0
type.[1]interface {} SRODATA dupok size=72
0x0000 10 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ................
0x0010 50 91 5b fa 02 08 08 11 00 00 00 00 00 00 00 00 P.[.............
0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x0040 01 00 00 00 00 00 00 00 ........
rel 24+8 t=1 runtime.algarray+144
rel 32+8 t=1 runtime.gcbits.03+0
rel 40+4 t=5 type..namedata.*[1]interface {}-+0
rel 44+4 t=6 type.*[1]interface {}+0
rel 48+8 t=1 type.interface {}+0
rel 56+8 t=1 type.[]interface {}+0
type..importpath.fmt. SRODATA dupok size=6
0x0000 00 00 03 66 6d 74 ...fmt
gclocals·7d2d5fca80364273fb07d5820a76fef4 SRODATA dupok size=8
0x0000 03 00 00 00 00 00 00 00 ........
gclocals·dc990f0ce5208716c4d33a75f4225a61 SRODATA dupok size=11
0x0000 03 00 00 00 04 00 00 00 00 0c 03 ...........
gclocals·8f9cec06d1ae35cc9900c511c5e4bdab SRODATA dupok size=9
0x0000 01 00 00 00 03 00 00 00 03 .........
gclocals·33cdeccccebe80329f1fdbee7f5874cb SRODATA dupok size=8
0x0000 01 00 00 00 00 00 00 00 ........
With "ok" check:
"".typeAssert STEXT nosplit size=47 args=0x18 locals=0x0
0x0000 00000 (assert-check.go:19) TEXT "".typeAssert(SB), NOSPLIT, $0-24
0x0000 00000 (assert-check.go:19) FUNCDATA $0, gclocals·8f9cec06d1ae35cc9900c511c5e4bdab(SB)
0x0000 00000 (assert-check.go:19) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (assert-check.go:19) MOVQ "".value+8(SP), AX
0x0005 00005 (assert-check.go:19) LEAQ type.*"".Context(SB), CX
0x000c 00012 (assert-check.go:20) CMPQ AX, CX
0x000f 00015 (assert-check.go:20) JNE 40
0x0011 00017 (assert-check.go:20) MOVQ "".value+16(SP), AX
0x0016 00022 (assert-check.go:20) JNE 30
0x0018 00024 (assert-check.go:21) MOVQ AX, "".~r1+24(SP)
0x001d 00029 (assert-check.go:21) RET
0x001e 00030 (assert-check.go:23) MOVQ $0, "".~r1+24(SP)
0x0027 00039 (assert-check.go:23) RET
0x0028 00040 (assert-check.go:23) MOVL $0, AX
0x002d 00045 (assert-check.go:20) JMP 22
0x0000 48 8b 44 24 08 48 8d 0d 00 00 00 00 48 39 c8 75 H.D$.H......H9.u
0x0010 17 48 8b 44 24 10 75 06 48 89 44 24 18 c3 48 c7 .H.D$.u.H.D$..H.
0x0020 44 24 18 00 00 00 00 c3 b8 00 00 00 00 eb e7 D$.............
rel 8+4 t=15 type.*"".Context+0
Without "ok" check:
"".typeAssert STEXT nosplit size=32 args=0x18 locals=0x0
0x0000 00000 (assert-nocheck.go:19) TEXT "".typeAssert(SB), NOSPLIT, $0-24
0x0000 00000 (assert-nocheck.go:19) FUNCDATA $0, gclocals·8f9cec06d1ae35cc9900c511c5e4bdab(SB)
0x0000 00000 (assert-nocheck.go:19) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (assert-nocheck.go:19) MOVQ "".value+8(SP), AX
0x0005 00005 (assert-nocheck.go:19) LEAQ type.*"".Context(SB), CX
0x000c 00012 (assert-nocheck.go:20) CMPQ AX, CX
0x000f 00015 (assert-nocheck.go:20) JNE 28
0x0011 00017 (assert-nocheck.go:20) MOVQ "".value+16(SP), AX
0x0016 00022 (assert-nocheck.go:21) MOVQ AX, "".~r1+24(SP)
0x001b 00027 (assert-nocheck.go:21) RET
0x001c 00028 (assert-nocheck.go:21) MOVL $0, AX
0x001e 00030 (assert-nocheck.go:20) JMP 22
0x0000 48 8b 44 24 08 48 8d 0d 00 00 00 00 48 39 c8 75 H.D$.H......H9.u
0x0010 0b 48 8b 44 24 10 48 89 44 24 18 c3 31 c0 eb f6 .H.D$.H.D$..1...
rel 8+4 t=15 type.*"".Context+0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment