Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

go - How to have shared utility functions in a github repo comprised of multiple apps?

Suppose I have a private github repository (called company_repo) belonging to a company I work for consisting of 3 separate Go applications and I want to use utility functions from folder util (util is basically functioning like an internal package for apps 1 through 3). I did a go mod init inside the util directory. I've tried adding github.com/company_repo/util v0.0.1 into the require directive in go.mod for app1, but unfortunately I get fatal: Could not read from remote repository.

.
├── app2
├── app3
├── README.md
├── app1
└── util
  1. Is this the right way to avoid sharing code between app1, app2, and app3? Basically trying to reuse database connection/logic code and some other common use cases between apps 1 thru 3 (e.g., fetching of common secrets).
  2. How do I get apps 1 thru 3 to fetch the "util" module and associated functions for use in apps 1 thru 3?
question from:https://stackoverflow.com/questions/65895056/how-to-have-shared-utility-functions-in-a-github-repo-comprised-of-multiple-apps

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...