Golang-链接到ID的套接字切片以进行通知

I want to make a slice of struct which contains an id and a socket to send notifications from my server. Each socket have to be initialized and I understand how a socket works because I already worked with it (in C, clustering for school project with select()).

However I don't understand how can I separate each new connection into a element of my slice (When I read the example from systembash).. It's hard to say what I don't understand, message me if you don't understand !

Thank!

Make a struct that includes both the conn and id:

type ConnDetails struct {
   connection net.Conn
   id         int
}

Use this to initialize your slice:

var connections []ConnDetails

Then, you can add all connections into this slice.

Is this what you were looking for?