Following the package structure
go_experiments
-module_1
-package_1
-package_1.go
-package_2
-package_2.go
-sample_file_1.go //Q1: Why is this file mandatory? I was getting error without this file
-go.mod
-module_2
-go.mod //requires module_1
-sample_file_2.go //this file calls method which are located inside package_2.go file
-consume
-go.mod // Q2: Why do I have to 'require' module_1 and module_2 ? I should just require module_2 and this package doesnt care what module_2 requires, the dependencies should be resolved automatically
-main.go //This calls method which is located in sample_file_2
Question1: Why is the file sample_file_1.go mandatory? I was getting error without this file?
Question 2: The consume module calls sample_file_2.go which is located in module_2.Therefore it just needs to require module_2 in the go.mod. However I find out its giving error and the error is resolved once I include module_1 as well. Therefore the question is how to deal with this situation? It cannot be expected for every child module to include/require its parent moduleā>grand module---->grand grand modules ā> and higher up the hierarchy. Is mentioning the lineage necessary in the go.mod file or I am missing something?