Call a function from another package in Go

前端 未结 5 450
予麋鹿
予麋鹿 2020-12-29 17:33

I have two files main.go which is under package main, and another file with some functions in the package called functions.

My question is:

5条回答
  •  旧巷少年郎
    2020-12-29 18:24

    you can write

    import(
      functions "./functions" 
    )
    func main(){
      c:= functions.getValue() <-
    }
    

    If you write in gopath write this import functions "MyProj/functions" or if you are working with Docker

提交回复
热议问题