title: Golang global setup for all tests (within same and other sub modules).
body: <p>I generally try to run the command <code>go test ./...</code> for CI/CD pipeline which used to run all test cases among all the subdirectories.</p>
  
  <p>But I recently refactored my code to take config file path from flag parsing and then reading and initializing all variables(required before server startup).This change required to remove all initialization code from 
  <code>init function -&gt; custom function</code> which will be called from main.  </p>
  
  <p>Now everything relates is done but all test cases are not working as I need to call all the custom functions from somewhere.</p>
  
  <p>I tried using the TestMain feature but I think it is only working for the same module and all test cases are failing.</p>
  
  <pre><code>func TestMain(m *testing.M) { 
      mySetupFunction()
      retCode := m.Run()
      myTeardownFunction()
      os.Exit(retCode)
  }
  </code></pre>
  
  <p>Need help to know how can I create a global test setup or would like to know is there any other better way for above-mentioned refactoring.</p>
  
  <p>I have my modules structure as follow</p>
  
  <pre><code>A
      B
      C
      D
          E
              F
          G
              H
      I
  main.go 
  </code></pre>
  
  <p>where parent module is A which contains main.go and various others module some nested to the deep level and all of them are having their own test cases</p>