function.go文件内容:
package main
import (
"errors"
)
func Add(a int, b int) (sum int, err error){
if a<0 || b<0 {
err = errors.New("请输入正整数")
return
}
return a+b, nil
}
functionTest.go文件内容:
package main
import (
"fmt"
)
func main() {
a, err := Add(-2,3)
fmt.Println(a,err)
}
报错:
# command-line-arguments
com\coreware\main\functionTest.go:10: undefined: Add
更多评论