0

Use Case: I have Proj A and Proj B. Proj B depends on Proj A. I am using Go Modules for dependency management and go mod vendor for generating the vendor folder. Proj A is inside the vendor folder of Proj B.

Issue: In Proj A, I have an HTML file. The HTML file is not copied to the vendor folder.

How can I force to copy the HTML file to the vendor folder so that I can use in Proj B?

Sathesh
  • 6,323
  • 6
  • 36
  • 48
  • 1
    Vendoring is generally for importing libraries which would be made up of Go code. Trying to vendor an HTML file is an extremely unusual use case and seems like an XY Problem. Can you describe your use case in more detail? There's probably a better way to accomplish your goals here. – Adrian Jan 21 '19 at 18:48
  • I have a common project which is inherited by multiple projects. It has some common html templates which is applicable to all of its dependent projects. – Sathesh Jan 21 '19 at 18:54
  • 1
    Having the HTML file in /vendor is pretty useless, because there is no useful way to refer to that file. You should probably define a Go variable instead, that holds the HTML string. `var HTML = []byte(\`...\`)` – Peter Jan 21 '19 at 19:02
  • Or maybe use submodules or something like that. Go libraries are for importing Go code. – Adrian Jan 21 '19 at 19:11

1 Answers1

0

A workaround for this issue is to have a dummy go file and go function in the html folder, and call the dummy function somewhere in the code. This makes the go mod vendor to copy the folder to the vendor folder. Not a cleaner way, until Go mod adds something like non-go=true option in deps.

Sathesh
  • 6,323
  • 6
  • 36
  • 48