title: how to test the result in goroutine without wait in test
body: <p>When I do ut of golang, I sometimes need to test the result in goroutine, I was using time.Sleep to test, I am wondering is there any better way to test.</p>
  
  <p>let's say I have an example code like this</p>
  
  <pre><code>func Hello() {
      go func() {
          // do something and store the result for example in db
      }()
      // do something
  }
  </code></pre>
  
  <p>Then when I test the func, I want to test both result in goroutine,
  I am doing this:</p>
  
  <pre><code> func TestHello(t *testing.T) {
          Hello()
          time.Sleep(time.Second) // sleep for a while so that goroutine can finish
          // test the result of goroutine
   }
  </code></pre>
  
  <p>is there any better way to test this?</p>
  
  <p>Basically, in real logic, I don't care the result in goroutine, I don't need to wait for it finished. but in test, I want to check after it finished.</p>