title: Set the time for connection's life in Golang
body: <p>I am a novice in golang and I am writing a client-server application through the TCP protocol. I need to make a temporary connection, which will close after a couple of seconds. I don't understand how to do that.<br>
  I have a such function, which creates a connection and waits for gob data:</p>
  
  <pre><code>    func net_AcceptAppsList(timesleep time.Duration) {
          ln, err := net.Listen("tcp", ":"+conf.PORT)
          CheckError(err)
          conn, err := ln.Accept()
          CheckError(err)
          dec := gob.NewDecoder(conn)
          pack := map[string]string{}
          err = dec.Decode(&amp;pack)
          fmt.Println("Message:", pack)
          conn.Close()
  }
  </code></pre>
  
  <p>I need to make this function to wait for data for only some seconds - not forever.</p>