Skip to content

Instantly share code, notes, and snippets.

@shogo82148
Created October 28, 2017 05:53
Show Gist options
  • Save shogo82148/465ab8cff76eaaa325c7b0c15d8250f6 to your computer and use it in GitHub Desktop.
Save shogo82148/465ab8cff76eaaa325c7b0c15d8250f6 to your computer and use it in GitHub Desktop.
const vs var
package main
import (
"fmt"
)
func main() {
const (
x = 0.3
y = 0.2
z = 0.1
)
a := x - y
b := y - z
c := a == b
fmt.Println(c)
}
package main.go:
func init func()
var init$guard bool
func main func()
# Name: main.go.init
# Package: main.go
# Synthetic: package initializer
func init():
0: entry P:0 S:2
t0 = *init$guard bool
if t0 goto 2 else 1
1: init.start P:1 S:1
*init$guard = true:bool
t1 = fmt.init() ()
jump 2
2: init.done P:2 S:0
return
# Name: main.go.main
# Package: main.go
# Location: main.go:7:6
# Locals:
# 0: t0 float64
# 1: t1 float64
# 2: t2 bool
func main():
0: entry P:0 S:0
t0 = local float64 (a) *float64
*t0 = 3602879701896397/36028797018963968:float64
t1 = local float64 (b) *float64
*t1 = 3602879701896397/36028797018963968:float64
t2 = local bool (c) *bool
t3 = *t0 float64
t4 = *t1 float64
t5 = t3 == t4 bool
*t2 = t5
t6 = *t2 bool
t7 = new [1]interface{} (varargs) *[1]interface{}
t8 = &t7[0:int] *interface{}
t9 = make interface{} <- bool (t6) interface{}
*t8 = t9
t10 = slice t7[:] []interface{}
t11 = fmt.Println(t10...) (n int, err error)
rundefers
return
package main
import (
"fmt"
)
func main() {
var (
x = 0.3
y = 0.2
z = 0.1
)
a := x - y
b := y - z
c := a == b
fmt.Println(c)
}
# Package: main.go
# Synthetic: package initializer
func init():
0: entry P:0 S:2
t0 = *init$guard bool
if t0 goto 2 else 1
1: init.start P:1 S:1
*init$guard = true:bool
t1 = fmt.init() ()
jump 2
2: init.done P:2 S:0
return
# Name: main.go.main
# Package: main.go
# Location: main.go:7:6
# Locals:
# 0: t0 float64
# 1: t1 float64
# 2: t2 float64
# 3: t3 float64
# 4: t7 float64
# 5: t11 bool
func main():
0: entry P:0 S:0
t0 = local float64 (x) *float64
*t0 = 5404319552844595/18014398509481984:float64
t1 = local float64 (y) *float64
*t1 = 3602879701896397/18014398509481984:float64
t2 = local float64 (z) *float64
*t2 = 3602879701896397/36028797018963968:float64
t3 = local float64 (a) *float64
t4 = *t0 float64
t5 = *t1 float64
t6 = t4 - t5 float64
*t3 = t6
t7 = local float64 (b) *float64
t8 = *t1 float64
t9 = *t2 float64
t10 = t8 - t9 float64
*t7 = t10
t11 = local bool (c) *bool
t12 = *t3 float64
t13 = *t7 float64
t14 = t12 == t13 bool
*t11 = t14
t15 = *t11 bool
t16 = new [1]interface{} (varargs) *[1]interface{}
t17 = &t16[0:int] *interface{}
t18 = make interface{} <- bool (t15) interface{}
*t17 = t18
t19 = slice t16[:] []interface{}
t20 = fmt.Println(t19...) (n int, err error)
rundefers
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment