jincheng9 / go-tutorial

Go learning materials,涵盖基础、中级和高级教程

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lesson8: 函数,闭包和方法(可以再补充一点:函数高级用法)

Chao2020x opened this issue · comments

package main

import "fmt"
import "math"

// define function getSquareRoot1
func getSquareRoot1(x float64) float64 {
return math.Sqrt(x)
}

// deffine a function variable
var getSquareRoot2 = func(x float64) float64 {
return math.Sqrt(x)
}

// deffine a function variable ========================补充
var getSquareRoot3 = math.Sqrt