I am converting my code base to use modules but am having issues with imports of downloaded modules inside of a package inside the repo. The link to my repo is below. Whenever I try any go get command, it can’t seem to find the excelize library even though it is included within the go.mod file. I have spent about 2 hours digging at this and have been unable to solve it. I am new to modules so there is probably something I am missing.
go.mod, when created at root repository, must have associated go source codes next to it. The only Go source code I found is inside DrugRecord/DrugRecord. You might want to shift it out to root level (DrugRecord) and reinitialize go.mod.
go.mod is now in the root directory (I deleted and re “go mod init …” for it) and I moved the rest of the code up to that level as well since the nesting was a mistake I had been too lazy to fix. However, I still get the following after trying to run.
NOTE: I edited the links to have a space after the dot and before the com so that they are not picked up as links. Other then that, this output was copy and pasted in
go: finding module for package github. com/gorilla/mux
go: finding module for package github. com/360EntSecGroup-Skylar/excelize
go: finding module for package github. com/lib/pq
go: finding module for package github. com/sqweek/dialog
go: found github. com/gorilla/mux in github. com/gorilla/mux v1.7.4
go: found github. com/360EntSecGroup-Skylar/excelize in github. com/360EntSecGroup-Skylar/excelize v1.4.1
go: found github. com/lib/pq in github. com/lib/pq v1.6.0
go: found github. com/sqweek/dialog in github. com/sqweek/dialog v0.0.0-20200601143742-43ea34326190
# github. com/bconn98/DrugRecord/mainUtils
mainUtils\excelWriter.go:30:22: file.MergeCell(acName, “A7”, “C7”) used as value
mainUtils\excelWriter.go:31:22: file.MergeCell(acName, “D7”, “F7”) used as value
mainUtils\excelWriter.go:32:22: file.MergeCell(acName, “A9”, “F9”) used as value
mainUtils\excelWriter.go:37:29: file.SetCellFormula(acName, “G” + strconv.Itoa(i), “=G” + strconv.Itoa(i - 1) + " + C" + strconv.Itoa(i) + “- F” + strconv.Itoa(i)) used as value
mainUtils\excelWriter.go:45:33: undefined: excelize.StreamWriter
mainUtils\excelWriter.go:48:22: undefined: excelize.Cell
mainUtils\excelWriter.go:51:3: undefined: excelize.Cell
mainUtils\excelWriter.go:203:33: undefined: excelize.StreamWriter
mainUtils\excelWriter.go:231:35: undefined: excelize.StreamWriter
mainUtils\excelWriter.go:255:33: undefined: excelize.StreamWriter
mainUtils\excelWriter.go:51:3: too many errors
I expect everything before the #, but everything after that is instances of using the excelize library which is imported and appears to be caught as dependency by the modules.
go.mod was missing at root repository. Fixed after guidance as per Github ticket.
https://github.com/bconn98/DrugRecord/blob/modules/mainUtils/excelWriter.go is still importing version 1.4.1 instead of the desired v2 version. This threw a lot of missing functions error as expected. After fixing the import statement and require clause, the library code is now working.