導入如何調用一個函數,它未在golang如何調用一個函數,它未在golang
mypkg.go
package mypkg
import "fmt"
func Test(){
fmt.Println("test")
}
要導入的包的包main.go
package main
func main(){
// I didn't import the package "mypkg"
// How to invoke the function named Test() of package "mypkg"
}
我需要你幫忙,謝謝。
作爲TheHippo解釋必須導入包。但問題依然存在:爲什麼你不想這麼做?你的用例是什麼? – Danilo
如果你不導入包,它不會被編譯並鏈接到你的二進制文件中,所以它基本上不存在。你真的想做什麼? – JimB
我打算使用一個簡單的web框架(使用php之前).split url路徑來實例化並調用指定的控制器和動作。@ Danilo – yrssoft