Print format and value type cannot be inconsistent

package main

import "fmt"

func FmtNum(val interface{}) string {
	return fmt.Sprintf("%d", val)
}

func main() {
	a := "woqoo"
	fmt_a := FmtNum(a)
	fmt.Println(fmt_a)
	b := 10
	fmt_b := FmtNum(b)
	fmt.Println(fmt_b)
	c := 10.1
	fmt_c := FmtNum(c)
	fmt.Println(fmt_c)
}


return fmt.Sprintf("%d", val)这一行存在byted format value type inconsistent的问题
运行以上代码的结果:
Print format and value type cannot be inconsistent_第1张图片

你可能感兴趣的:(golang)