英文:
Setting GOOGLE_APPLICATION_CREDENTIALS
问题
我正在进行一个Go项目。我想创建一个.env文件。我参考了文档,但是我不明白如何创建它,将文件放在哪里以及如何使用它。你们能帮助我吗?
链接:https://firebase.google.com/docs/firestore/quickstart#go
英文:
I am working on a Go project. I want to create an .env file. I refer to the docs but I am not understanding how to do it & where to put that file & how can I use it? Can you guys please help me?
Link: https://firebase.google.com/docs/firestore/quickstart#go
答案1
得分: 1
如果你想在Golang中加载一个.env文件,你可以使用github.com/joho/godotenv模块。然后,你可以使用godotenv.Load()来加载你的文件。
我通常更喜欢使用direnv,并为每个项目创建一个.envrc文件,这样我就可以使用os库并加载环境变量 ![]()
英文:
If you want to load a .env file in Golang, you can use the github.com/joho/godotenv module. Then, you can load your file with godotenv.Load().
I usually prefer to use direnv and have .envrc for each of my project so I can just the os lib and load the environment variables ![]()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论