Skip to content

Golang - go get -d is deprecated #27

Open

Description

@Yodazon

In the Golang docs it states that "Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead."

The example runs when changing the installation to "go install". Is it alright for me to fork and create a PR with the changes?

Activity

  1. vs41 commented on Dec 15, 2025

    @vs41

    Actually, I am getting a timeout when trying to connect to the socket. Could you please help me ?
    2025/12/15 15:02:21 read tcp 192.168.****.:44530->136.243.173.177:443: i/o timeout

    func startAISStream(ctx context.Context, pool *pgxpool.Pool, apiKey string) {

    url := "wss://stream.aisstream.io/v0/stream"
    fmt.Println("web socket is about to start")
    ws, _, err := websocket.DefaultDialer.Dial(url, nil)
    if err != nil {
    	log.Fatalln(err)
    }
    defer ws.Close()
    
    subMsg := aisstream.SubscriptionMessage{
    	APIKey:        apiKey,
    	BoundingBoxes: [][][]float64{{{-90.0, -180.0}, {90.0, 180.0}}}, // bounding box for the entire world
    }
    
    subMsgBytes, _ := json.Marshal(subMsg)
    if err := ws.WriteMessage(websocket.TextMessage, subMsgBytes); err != nil {
    	log.Fatalln(err)
    }
    
    for {
    	_, p, err := ws.ReadMessage()
    	if err != nil {
    		log.Fatalln(err)
    	}
    	var packet aisstream.AisStreamMessage
    
    	err = json.Unmarshal(p, &packet)
    	if err != nil {
    		log.Fatalln(err)
    	}
    
    	var shipName string
    	// field may or may not be populated
    	if packetShipName, ok := packet.MetaData["ShipName"]; ok {
    		shipName = packetShipName.(string)
    	}
    
    	switch packet.MessageType {
    	case aisstream.POSITION_REPORT:
    		var positionReport aisstream.PositionReport
    		positionReport = *packet.Message.PositionReport
    		fmt.Printf("MMSI: %d Ship Name: %s Latitude: %f Longitude: %f\n",
    			positionReport.UserID, shipName, positionReport.Latitude, positionReport.Longitude)
    	}
    
    }
    

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions