title: Why Calling Setenv from code Not Working?
body: <p>I have a simple test project which is expected to print goroutine scheduling messages while it is running. </p>
  
  <p>Setting the env from Goland configuration it works. but it doesn't from code like below, the app doesn't print scheduling infomation. Anybody explains what happens ehre?</p>
  
  <pre><code>func TestScheduler1() {
  
      var wg sync.WaitGroup
      wg.Add(10)
  
      for i := 0; i &lt; 10; i++ {
          go work(&amp;wg)
      }
  
      wg.Wait()
      // Wait to see the global run queue deplete.
      time.Sleep(3 * time.Second)
  }
  
  func work(wg *sync.WaitGroup) {
      time.Sleep(time.Second)
  
      var counter int
      for i := 0; i &lt; 1e10; i++ {
          counter++
      }
  
      wg.Done()
  }
  </code></pre>
  
  <p>init function is like:</p>
  
  <pre><code> func init()  {
      os.Setenv("GOMAXPROCS", "1")
      os.Setenv("GODEBUG", os.Getenv("GODEBUG") + "schedtrace=1000,scheddetail=1")
  }
  </code></pre>