Call a function from another package in Go

前端 未结 5 446
予麋鹿
予麋鹿 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 import the package by its import path, and reference all its exported symbols (those starting with a capital letter) through the package name, like so:

    import "MyProj/functions"
    
    functions.GetValue()
    

提交回复
热议问题