Loading...

Follow The Go Programming Language on Feedspot

Continue with Google
Continue with Facebook
or

Valid

Hello,

I've noticed that when using IPv6 addresses with a zone indication the url.Parse package will fail due to Invalid URL escape "%". This will cause a problem with the github.com/eclipse/paho.mqtt.golang/ package when trying to connect to a IPv6 broker.

The problem area: ```go func (o *ClientOptions) AddBroker(server string) *ClientOptions { if len(server) > 0 && server[0] == ':' { server = "127.0.0.1" + server } if !strings.Contains(server, "://") { server = "tcp://" + server }

brokerURI, err := url.Parse(server) if err != nil { ERROR.Println(CLI, "Failed to parse %q broker address: %s", server, err) return o } o.Servers = append(o.Servers, brokerURI) return o }

```

An example: ```go package main

import ( MQTT "github.com/eclipse/paho.mqtt.golang" "log" )

var handler MQTT.MessageHandler = func(client MQTT.Client, msg MQTT.Message) { log.Println(msg.Payload()) }

func main() { log.SetFlags(log.Lshortfile | log.Ltime) ipaddr := "[fe80::a604:5838:8d8a:e532%wlp58s0]:1883" opts := MQTT.NewClientOptions().AddBroker(ipaddr) opts.SetClientID("Client") opts.OnConnect = func(c MQTT.Client) {

 if token := c.Subscribe("testTopic", 0, handler); token.Wait() && token.Error() != nil { log.Println(token.Error()) } } client := MQTT.NewClient(opts) token := client.Connect() if token.Wait() && token.Error() != nil { log.Fatal(token.Error()) } if !client.IsConnected() { log.Fatal("Failed to connect to server:" + ipaddr) } 

}

```

I'm not sure if this is a bug in github.com/eclipse/paho.mqtt.golang/ or the net/url package?

Or doesn't github.com/eclipse/paho.mqtt.golang/ project support IPv6?

I know that you can solve this by adding a 25 before the zone.

The result would look like this: tcp://[fe80::a604:5838:8d8a:e532%25wlp58s0]:1883.

However this breaks the compatibility between IPv6 addresses and the mqtt broker.

Is this really a bug as I suspect or is it a User error?

Best regards,

submitted by /u/Mattemagikern
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

I have never coded before and wanted to learn the basics on go lang. I followed the download instructions on the go lang website, yet when I open the go lang file it brings a black screen that I cannot type on. Did I not complete the whole process?

submitted by /u/joebaseball3
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

I added the olivere/elasticsearch library in my codebase without specifying the version and it added the version of 6 the library, now I want to replace that with version 5 using dep. How do I do that?

submitted by /u/fenster25
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Those of you have interviewed for golang programming jobs, is it mostly using hackerrank or whiteboarding? Leetcode in Go?

Do you mind sharing a little bit of your experience?

Thanks!

submitted by /u/reprogram5
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hi guys, I want to share some code that I've written:

fuzzy-patricia is a Go implementation of a Patricia-Trie with the ability to do fast fuzzy and substring on the inserted keys. It is a fork of go-patricia, with the additional features and memory/performance optimizations.

You should use it if:

  • You need to store a load of strings in memory
  • Need to associate some data with each string
  • Need to retrieve all strings with a given prefix (and the associated data) in no time
  • Need to retrieve all strings that contain a given sub-string in little time
  • Need to do fuzzy matching on the strings in little time
  • Don't have a lot of memory to spare

I use this data structure in a different project, where I index my whole file system, around 2.3 million files, using only 200mb of memory. Most substring/fuzzy queries take somewhere near 100ms on this data set, the prefix queries run in a matter of nanoseconds.

If you are a Linux user, please take a look (it's also written in go): gosearch

Cheers!

submitted by /u/ozeidan
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hello! Doing a bit of research into the go programming language. And for more of the sake of curiosity, how would one compile the Go source code without Go? Is there a version that was written in another language and didn't need Go to make a Go binary?

submitted by /u/SuperbLunch
[visit reddit] [comments]
Read Full Article

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview