Yep I did this in the end and it works fine...
var user string
for rows_users.Next() {
rows_users.Scan(&user)
if conn, ok := m[user]; ok {
conn.Write([]byte(string(username + " has entered the
room\n# ")))
}
}
I think I will back off the project and go back to the docs as you suggest
rather than ploughing through every problem I come across...as fun as that
can be.
On Saturday, September 12, 2020 at 8:02:31 PM UTC+1 [email protected] wrote:
> On Saturday, 12 September 2020 19:36:18 UTC+1, Andy Hall wrote:
>>
>> to handle the map not returning a result ( so I don't attempt to
>> write to a non-existent connection ) I need to know the zero value of
>> type net.Conn
>>
>>
> net.Conn is an interface <https://golang.org/pkg/net/#Conn>, and
> therefore its zero value is "nil".
>
> Note though that you don't need to know the zero value of a type to
> determine whether it's in a map or not. Use the two-value assignment form
> <https://tour.golang.org/moretypes/22> (value, ok := ...) to test if the
> value exists.
>
> Running through the whole of tour.golang.org is highly recommended.
> Several times :-)
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/91df4313-dfdc-4bc0-989d-82751655a1aen%40googlegroups.com.