After checking with gometalinter this part of code:
//ListenerButton is hanging listeners for contact button
func ListenerButton(number int, button *ui.Button, conn net.Conn) string {
button.OnClicked(func(*ui.Button) {
sliceMembers := []string{login, button.Text()}
groupName = login + button.Text()
_, err := conn.Write([]byte(JSONencode(login, "", "",
0, groupName, 1,
login, sliceMembers, " ", " ", "",
" ", " ", " ", true, " ", "CreateGroup")))
if err != nil {
log.Println(err)
}
fmt.Println(login, groupName, number, "graphic 131")
})
return groupName
}
I've got this warning:
warning: conn can be io.Writer (interfacer)
What does it mean and how i have to resolve it?
That means that the ListenerButton
function is only only using the Write
method of conn
. By changing the type from net.Conn
to io.Writer
, that allows your function to use a much larger number of io.Writer
implementations. Having as small of interfaces as possible should be a goal when implementing your API.
With that change, for example, you could use an io.MultiWriter
to write debug information to stderr, as well as the network connection:
func ListenerButton(number int, button *ui.Button, conn io.Writer) string {
// ...
}
ListenerButton(number, button, io.MultiWriter(os.Stderr, networkConn))