test
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m46s

This commit is contained in:
matst80
2024-11-10 00:03:45 +01:00
parent a82e4f10fe
commit 9b75b872ee

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"io" "io"
"log"
"net" "net"
"strings" "strings"
"sync" "sync"
@@ -33,9 +34,6 @@ type RemoteGrain struct {
} }
func NewRemoteGrain(id CartId, address string) *RemoteGrain { func NewRemoteGrain(id CartId, address string) *RemoteGrain {
if !strings.Contains(address, ":") {
address = fmt.Sprintf("[%s]:1337", address)
}
return &RemoteGrain{ return &RemoteGrain{
Id: id, Id: id,
Address: address, Address: address,
@@ -44,7 +42,12 @@ func NewRemoteGrain(id CartId, address string) *RemoteGrain {
func (g *RemoteGrain) Connect() error { func (g *RemoteGrain) Connect() error {
if g.connection == nil { if g.connection == nil {
client, err := net.Dial("tcp", g.Address) addr := g.Address
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:1337", addr)
}
log.Println("Connecting to", addr)
client, err := net.Dial("tcp", addr)
if err != nil { if err != nil {
return err return err
} }