[go-nuts] Re: Simple web crawler question. How to avoid crawling visited links?

2017-09-25 Thread Aaron
<-done lock.Lock() (*visited)[result] = true lock.Unlock() ch <- result } } } } func getHrefTag(token html.Token) (result string, ok bool) { for _, a := range token.Attr { if a.Key == "href"

[go-nuts] How to remove a struct value from a struct slice without memory leak?

2017-09-25 Thread Aaron
Newbie here everyone. I am trying to remove a struct value from a slice, which consists of elements of the same type. Let's say the type is defined as below: type connInfo struct { ipAddr string name string conn net.Conn } Now I have a remove function, in which there is a for loop

Re: [go-nuts] How to remove a struct value from a struct slice without memory leak?

2017-09-25 Thread Aaron
Thanks I also worried that at the beginning. But when I use this code I find it works correctly. But if I pull it out to test the individual function it doesn't look good. I think you are right the best practice is to return the slice. For the connInfo struct comparison I learned that comparing

[go-nuts] Re: Simple web crawler question. How to avoid crawling visited links?

2017-09-25 Thread Aaron
Wow this has everything for a crawler plus many more. Is it good to put the code into so many files? I thought go program is simple enough to put most code into one file. But I think if code reuse is the main concern maybe this is good. On Monday, September 25, 2017 at 10:44:45 PM UTC+8, Tim T

Re: [go-nuts] Re: Simple web crawler question. How to avoid crawling visited links?

2017-09-25 Thread Aaron
ocesses that read WORK, fetch the url, do whatever >> it it that you need to do, and for urls found there, writes them to PENDING >> >> this is enough. now as written you have the challenge to know when the >> workers are done and pending is empty. that's when you exi

[go-nuts] Rewriting a realtime game server from Node.js to Golang

2017-10-01 Thread Aaron
Hi I am in a process of rewriting a realtime game server from Node.js to Golang. It's two to three thousand lines of code in Node.js. But I have no previous Golang experience so it's hard to measure the workload. Do you think it is better for me to do some other bigger projects before I start r

[go-nuts] converting slice of items into nested array

2016-12-07 Thread aaron
I'm pretty new to golang and struggling a bit with converting flat database results into a nested JSON object. As an example... I have type item struct { raceID string racename string name string votesint32 } type race struct { raceID string racename string racers } type racers

[go-nuts] Re: Go routines hanging

2018-05-04 Thread Aaron Alpar
e outgoing connection. RedisWriteHandler will stall if either one of these outgoing requests hangs. While timeouts will not fix your problem, they will allow you to further diagnose the problem. - Aaron On Friday, May 4, 2018 at 7:24:56 AM UTC-7, s...@whites.team wrote: > > Hi all, &

[go-nuts] Question about iterator implementation of golang map

2019-07-15 Thread Aaron Lau
Question: Where In function mapiternext Why We won't update the map during the traversal process. So why use mapaccessK to find the k & v again ? if (b.tophash[offi] != evacuatedX && b.tophash[offi] != evacuatedY) || !(t.reflexivekey() || alg.equal(k, k)) { // This is the golden data, we can retu

Re: [go-nuts] dynamic frequency ticker

2016-08-30 Thread Aaron Cannon
. Aaron On 8/30/16, seb.st...@gmail.com wrote: > In my application I select on a ticker channel, but sometimes need to have > the waiting time vary a bit. For not so frequent changes I could make a new > > ticker everytime, but I have the feeling this is not the best solution

[go-nuts] Reasons why `go get` is entirely quiet by default

2016-10-13 Thread Aaron Taylor
It's also probably worth noting that 'go get' isn't really a package manager in the way that yarn and npm are. Each of those tools, and their go equivalents [1] have somewhat more sophisticated functionality related actually managing the packages, controlling their versions, resolving conflicts,

Re: [go-nuts] Re: Secure Go binaries

2016-12-22 Thread Aaron Wood
ntrol this setting...although I guess most of them don't really compile down to a native binary in the end. -Aaron On Monday, April 30, 2012 at 10:21:06 PM UTC-4, Russ Cox wrote: > > On Mon, Apr 30, 2012 at 21:51, David Leimbach > wrote: > > I was just playing with

Re: [go-nuts] Re: Secure Go binaries

2016-12-22 Thread Aaron Wood
27;re calling C from Go. There must be other rare, obscure ways to exploit overflows in code generated from Go, no? On Thursday, December 22, 2016 at 5:31:14 PM UTC-5, Ian Lance Taylor wrote: > > On Thu, Dec 22, 2016 at 2:09 PM, Aaron Wood > wrote: > > > > This is a rather

[go-nuts] Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
Hi all, I'm seeing a very strange issue that I'm not quite sure how to fix: https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L25 https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L80 This causes a data race, and of course we only see it when running on a beefy server

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
t; > > On Thursday, February 2, 2017 at 12:43:09 PM UTC-5, Aaron Wood wrote: >> >> Hi all, >> >> I'm seeing a very strange issue that I'm not quite sure how to fix: >> >> https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L25 >>

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
TypeOf(<-tokens) != reflect.TypeOf(*new(struct{})) { t.Fatal("Token is of the wrong type") } } On Thursday, February 2, 2017 at 1:43:12 PM UTC-5, James Bardin wrote: > > Can you post the actual output from the race detector? > > > On Thursday, February 2, 2017 at 12:43:0

Re: [go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
I can't unfortunately since it's private right now :( I can show you the entire back off source file here if you'd like, I just can't link you to anything right now. On Thursday, February 2, 2017 at 2:29:37 PM UTC-5, James Bardin wrote: > > Can you point to the actual source you're using? The fi

Re: [go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
auses the race detector to indicate the wrong lines in the source file. > > On Thu, Feb 2, 2017 at 11:33 AM, Aaron Wood > wrote: > >> I can't unfortunately since it's private right now :( I can show you the >> entire back off source file here if you'd like, I ju

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
UTC-5, Aaron Wood wrote: > > Hi all, > > I'm seeing a very strange issue that I'm not quite sure how to fix: > > https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L25 > https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L80 > > This causes

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
Oh man, it looks like you can't use covermode=count with race detection? https://github.com/golang/go/issues/12118 On Thursday, February 2, 2017 at 12:43:09 PM UTC-5, Aaron Wood wrote: > > Hi all, > > I'm seeing a very strange issue that I'm not quite sure how to

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
Sorry guys. False alarm. The real issue was that we needed to use covermode=atomic instead of covermode=count in our CI. On Thursday, February 2, 2017 at 12:43:09 PM UTC-5, Aaron Wood wrote: > > Hi all, > > I'm seeing a very strange issue that I'm not quite sure

Re: [go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread Aaron Wood
Thanks! I'm sure I'll never forget this experience :) -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options,

[go-nuts] Returning an interface using a concrete type?

2017-02-14 Thread Aaron Wood
I'm wondering why it's not possible to do something like this https://play.golang.org/p/UaRLUvhkgz If a type implements an interface then why can that type not be returned with the method specifying the return type as the interface that it implements? -- You received this message because you

Re: [go-nuts] Returning an interface using a concrete type?

2017-02-14 Thread Aaron Wood
hane wrote: > > Seems to work fine to me: https://play.golang.org/p/6DmDKQLrzd. > > In your snippet, the concrete type doesn't implement the interface, > however. What was the error you got when trying to do apply this to more > complicated code. > > Chris > >

[go-nuts] Generics: More on parens

2020-06-16 Thread Aaron Cannon
7;m really loving this! Thanks for all the hard work! Aaron -- This message was sent from a mobile device -- 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 a

Re: [go-nuts] Generics: More on parens

2020-06-17 Thread Aaron Cannon
ion is doing if you squint a bit. :) Anyway, just my $0.02. Thanks again for all the hard work on this. Aaron On 6/16/20, Ian Lance Taylor wrote: > On Tue, Jun 16, 2020 at 8:31 PM Aaron Cannon > wrote: >> >> I, like many others, am not fond of all the parenthesis, particularly

[go-nuts] Referencing a library name in a cgo comment whose name is known at build time

2021-04-28 Thread Aaron Epstein
so I don't think I can do // #cgo LDFLAGS: -lmy{VAR_NAME}lib And I don't have the option of setting the library name to be constant. Is there a way I can link with cgo here? Thanks, Aaron -- You received this message because you are subscribed to the Google Groups "go

Re: [go-nuts] Referencing a library name in a cgo comment whose name is known at build time

2021-04-28 Thread Aaron Epstein
Lance Taylor wrote: > On Wed, Apr 28, 2021 at 8:41 AM Aaron Epstein wrote: > > > > I have a C library that I am linking with from Go whose name is known at > build-time, and is not a constant I can write in a comment like > > // #cgo LDFLAGS: -lmylib > > > > The

[go-nuts] Build error from pragma warnings when doing "go build -buildmode=c shared..."

2021-05-20 Thread Aaron Epstein
: warning: ignoring #pragma GCC diagnostic _cgo_export.c:8: warning: ignoring #pragma GCC diagnostic CGO_ENABLED=1 is set as well. This is using go 1.13. Any ideas? Thanks, Aaron -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubs

Re: [go-nuts] Build error from pragma warnings when doing "go build -buildmode=c shared..."

2021-05-20 Thread Aaron Epstein
gcc Is there a way to see which version go is picking up? I have both 4.9.4 and 4.1.2. I suspect it is picking up 4.1.2 and this is the cause, but is there a way to tell? On Thursday, May 20, 2021 at 9:36:57 AM UTC-4 Ian Lance Taylor wrote: > On Thu, May 20, 2021, 4:47 AM Aaron Epstein wr

Re: [go-nuts] Build error from pragma warnings when doing "go build -buildmode=c shared..."

2021-05-20 Thread Aaron Epstein
Removing gcc 4.1.2 from PATH so it picked up 4.9.4 which resolved this issue. Still would be good to know if it is possible to know which gcc go is using... On Thursday, May 20, 2021 at 9:46:34 AM UTC-4 Aaron Epstein wrote: > gcc > > Is there a way to see which version go is pick

Re: [go-nuts] Is Go a security malware risk?

2022-08-23 Thread Aaron Rubesh
To this day the most prevalent, evasive and destructive malware is developed in C/C++... So may as well ban those languages too!! Seriously, if your answer to 'stopping malware written in Go' is to ban all applications written in Go, your security team needs some more training budget or you

Re: [go-nuts] Taking single value from multi-return function and inlining function calls

2022-08-29 Thread Aaron Rubesh
Another option for this is if your function is always called after the call to the external library, you can change your function signature to match the return value of the external library. Its quite common to see something like this: ` func A() (int, error) {} func UseA(a int, err error) (in

Re: [go-nuts] Non-mutable / readonly slices?

2022-10-20 Thread Aaron Rubesh
In general, no. Each time you pass around a []byte you are actually passing around a copy of a pointer to the slice. Modifications will affect the underlying slice. You can use arrays instead, which are always PBV. Take care though, if you try to pass an array to a function accepting a slice vi

[go-nuts] Parse JSON case-sensitively

2021-09-23 Thread &#x27;Aaron' via golang-nuts
Hi all Anyone know of a JSON package (or other solution) which is case-sensitive when decoding - and is also mature, simple, and parses into a struct? I've looked at a few open-source packages, but the ones I've found seem to be focused on performance, or allowing you to access the JSON in diffe

Re: [go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-06 Thread &#x27;Aaron Spangler' via golang-nuts
Thank you! You are correct. That was exactly my problem. Adding the equals sign (=) solved it. I guess I need to be more aware that sometimes an equals statement is required on a 'var' line and other times it is not. (perhaps only when it has a literal) Thanks again! On Thu, Jun 6, 2019 at 1

Re: [go-nuts] In-Method declaration of array of struct literals vs global var?

2019-06-07 Thread &#x27;Aaron Spangler' via golang-nuts
site literal expression. It could also be written as > > var bar []struct{a, b, c string} = []struct{a, b, c string} { > { "really", "long", "row"}, > { "many", "many", "rows"}, > ... > } > > On Thu, Jun 6, 2019 at 2

[go-nuts] Re: GDB support for goroutines in core files

2016-12-05 Thread &#x27;Aaron Jacobs' via golang-nuts
On Fri, Dec 2, 2016 at 7:32 PM, wrote: > Hello Aaron, have you figure it out yet? Sorry, I haven't done anything further here. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiv

[go-nuts] Is there a better way to write this?

2022-09-13 Thread &#x27;Aaron Spangler' via golang-nuts
I seem to be regularly working with maps of stringsets and I have found myself writing the same pattern over and over and I ended up having my own utility function. More importantly the syntax seems clunky when a key doesn't exist in the map. Is there a better way (go idiomatically way) to write

[go-nuts] Underlying type constraints and pointers

2022-10-21 Thread &#x27;Aaron Beitch' via golang-nuts
lar to those provided by golang.org/x/exp/maps and for those helpers to work on pointers to types whose underlying type is gomap.Map. Thanks, Aaron -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Underlying type constraints and pointers

2022-11-01 Thread &#x27;Aaron Beitch' via golang-nuts
rking how I want. So, what I can do instead is define an interface that includes the methods that Foo provides and use that as my constraint. https://go.dev/play/p/BwEb8Lm4pb6 Aaron On Friday, October 21, 2022 at 10:44:57 PM UTC-7 axel.wa...@googlemail.com wrote: > Actually (maybe I should sto

[go-nuts] Re: When do you recommend not using composition?

2023-04-28 Thread &#x27;Aaron Rubesh' via golang-nuts
I would recommend reading up on how to implement Go interfaces. The only requirement required to satisfy the io.Writer interface is a method Write([]byte)(int,error). If this method is present, Go can then interpret your struct as a io.Writer. By itself, io.Writer provides no functionality only