如何定义包级文件?

时间:2014-07-18 17:34:17

标签: go

我在包notifications

中有一个模板
/notifications
/html/notify.tpl

问题是,如果我从不同的路径/包中调用此包的函数,它将无法再找到该文件,因为程序假定该路径属于正在调用的包。 例如

ls
 main.go
/notifications
/html/notify.template

去运行main.go

open html/notify.tpl: no such file or directory

1 个答案:

答案 0 :(得分:1)

你没有。

您可以提供配置路径,使用众所周知的完全限定路径,使用相对于工作目录的路径(不推荐),或者三者的组合。