[go-nuts] Re: Design patterns. builder ?

2021-04-01 Thread Brian Candler
The builder pattern generally isn't needed in go, because go has flexible struct literals where you can omit any members you don't want. You can implement it if you like, but it just adds a layer of boilerplate: https://gist.github.com/vaskoz/10073335 Some people are drawn to functional options

Re: [go-nuts] Finding error type for `errors.As` and `errors.Is`

2021-04-01 Thread 'Michael Schaller' via golang-nuts
Roger, I think you slightly misunderstood me. ;-) It is true that `As` and `Is` methods can be used to allow `errors.As` and `errors.Is` to handle error types that aren't actually in the error chain. However my question was if an `errors.Chain` function which returns details about the error typ

Re: [go-nuts] Re: Design patterns. builder ?

2021-04-01 Thread Robert Engels
The Go protobufs impl uses the builder pattern. > On Apr 1, 2021, at 2:21 AM, Brian Candler wrote: > > The builder pattern generally isn't needed in go, because go has flexible > struct literals where you can omit any members you don't want. > > You can implement it if you like, but it just

Re: [go-nuts] Help with tcpserver

2021-04-01 Thread Perry Couprie
It works now i added the ReadDeadline, thanks for the help :-) Perry On Wednesday, March 31, 2021 at 1:22:20 PM UTC+2 Brian Candler wrote: > I think that in principle you are correct to perform your reads inside a > goroutine, to allow them to be received asynchronously. > > If Read() blocks, i

[go-nuts] GIL for Go

2021-04-01 Thread Amnon
An exciting announcement from the Go team this morning! The upcoming release of Go 1.17 (due in September) will include GIL for Go, As the Pythonistas among us know, GIL is Python’s Global Interpreter Lock, which has been included in even the earliest versions of Python, but is missing from Go u

Re: [go-nuts] GIL for Go

2021-04-01 Thread satyendra singh
Hilarious 🤣 Thanks and regards, Satyendra On Thu, Apr 1, 2021, 9:10 PM Amnon wrote: > An exciting announcement from the Go team this morning! > > The upcoming release of Go 1.17 (due in September) will include GIL for Go, > As the Pythonistas among us know, GIL is Python’s Global Interpreter Lo

Re: [go-nuts] GIL for Go

2021-04-01 Thread Artur Vianna
April 1st? You got me good on that last one On Thu, 1 Apr 2021, 12:41 Amnon, wrote: > An exciting announcement from the Go team this morning! > > The upcoming release of Go 1.17 (due in September) will include GIL for Go, > As the Pythonistas among us know, GIL is Python’s Global Interpreter Loc

[go-nuts] go list and GO111MODULE in Go 1.17

2021-04-01 Thread Dórian Langbeck
Hi all, We have a monorepo with a bunch of services in it. Currently, in Go 1.16, I'm able to build each service using "docker build -" and generating the tar context "by hand" using something like: go list -deps ./services/s1 | sed -n 's#^github.com/org/monorepo/##p' It works fine locally (as

[go-nuts] string matching

2021-04-01 Thread Sharan Guhan
Hi Experts, New to Golang and finding it non trivial to achieve the below efficiently :-) Any pointers will help.. I have a huge string as below .. Now from this I want to extract the number "18" after "Core count".. I was thinking of walking through each string with Spilt("\n"), but that will m

Re: [go-nuts] string matching

2021-04-01 Thread Artur Vianna
Try the regex: "Core Count: [0-9]+", then split on ":" and select the second part. On Thu, 1 Apr 2021, 15:28 Sharan Guhan, wrote: > Hi Experts, > > New to Golang and finding it non trivial to achieve the below efficiently > :-) Any pointers will help.. > > I have a huge string as below .. Now f

Re: [go-nuts] string matching

2021-04-01 Thread Matt KØDVB
Use a capture group regex := regexp.MustCompile(`.*\bCore Count: (\d+)`) result := regex.FindAllStringSubmatch(raw, -1) https://play.golang.org/p/r_TxhVZVfzE See also https://www.youtube.com/watch?v=XCE0psygwj8 > On Apr 1, 2021, at 12:32

Re: [go-nuts] string matching

2021-04-01 Thread Amnon
Or you could try something like https://play.golang.org/p/xkmchEgyVir On Thursday, 1 April 2021 at 20:02:29 UTC+1 Matt KØDVB wrote: > Use a capture group > > regex := regexp.MustCompile(`.*\bCore Count: (\d+)`) > result := regex.FindAllStringSubmatch(raw, -1) > > https://play.golang.org/p/r_TxhV

Re: [go-nuts] string matching

2021-04-01 Thread Michael Poole
You were on a good start with strings.Index(). The key is to move past the pattern you searched for, assuming it was found. Something like this should work, if `bigString` is what you are searching over, and depending on whether "Core Count:" might be on the first line or not: pattern := "\n

Re: [go-nuts] string matching

2021-04-01 Thread Sharan Guhan
Thanks Everyone for such good responses and for code pointers !!! It really helped me.. I have a long string with multiple such occurrences and I need to keep filling them into an array.. I consolidated all of your approaches and now have a working model as below.. func ParseandFillCpuInfo (cmd_o

[go-nuts] Re: go list and GO111MODULE in Go 1.17

2021-04-01 Thread Manlio Perillo
Il giorno giovedì 1 aprile 2021 alle 18:58:33 UTC+2 dorianl...@gmail.com ha scritto: > Hi all, > > We have a monorepo with a bunch of services in it. > Currently, in Go 1.16, I'm able to build each service using "docker build > -" and generating the tar context "by hand" using something like: g

[go-nuts] Alternate implementations of regular expression matching?

2021-04-01 Thread Bob Alexander
I have a use of regular expressions where I need the "atomic" matching features that I can get for several other languages, such as atomic matching groups and "possessive" quantifiers. I'm willing to forego the blazing performance of Go's standard library dfa matcher for this particular case. I can

[go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-01 Thread Brian Candler
If you can live with cgo dependencies, then you might want to look at a go wrapper around PCRE, which is the "go-to" implementation for fully-featured regexps. e.g. https://github.com/rubrikinc/go-pcre (untested by me, and it's one of several forks) -- You received this message because you a

[go-nuts] Regexp for matching Interface address

2021-04-01 Thread Sharan Guhan
Hi Experts, I am facing issues in getting the correct regexp for this use-case. Sorry for the 2nd question of the day :-( pci@:19:00.0 pci@:19:00.1 pci@:5e:00.2 pci@:5e:00.3 pci@:d8:00.0 pci@:d8:00.1 I need to fetch ":19:00.0" through ":d8:00.1" in a string.. I us

Re: [go-nuts] Regexp for matching Interface address

2021-04-01 Thread 'Axel Wagner' via golang-nuts
`strings.SplitN(s, "@", 2)[1]` Of course with additional handling for the case that there is no @ or more than one @. I know that "don't use regexp" may be a frustrating answer to this question, but IMO it's the correct one. Regular expressions are hard to maintain in production software. If you

Re: [go-nuts] Regexp for matching Interface address

2021-04-01 Thread Sharan Guhan
Thanks much ! This code just works like a charm in my use-case.. I learnt we can do 1.define # characters using "{4}" 2.Combine digits + alphabets using "[0-9a-f]" Sharan On Thu, Apr 1, 2021 at 1:48 PM Axel Wagner wrote: > `strings.SplitN(s, "@", 2)[1]` > > Of course with additional handling f

[go-nuts] Go 1.16.3 and Go 1.15.11 are released

2021-04-01 Thread Dmitri Shuralyov
Hello gophers, We have just released Go versions 1.16.3 and 1.15.11, minor point releases. View the release notes for more information: https://golang.org/doc/devel/release.html#go1.16.minor You can download binary and source distributions from the Go web site: https://golang.org/dl/ To

[go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-01 Thread Amnon
Worth mentioning Russ Cox's series of blog posts on Regular Expressions and their implementation https://swtch.com/~rsc/regexp/ On Thursday, 1 April 2021 at 21:21:14 UTC+1 Brian Candler wrote: > If you can live with cgo dependencies, then you might want to look at a go > wrapper around PCRE,

Re: [go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-01 Thread Marcin Romaszewicz
I have nothing useful to contribute to this discussion, however, I've been doing this long enough to remember Jamie Zawinski's quote about regular expressions :) Some people, when confronted with a problem, think "I know, I'll use > regular expressions." Now they have two problems. > https://blog

[go-nuts] Update to generics proposal

2021-04-01 Thread Ian Lance Taylor
We've just posted a potential update to the generics proposal at https://golang.org/issue/45346. This clarifies and simplifies the type lists that appear in interfaces, and let's us drop the "type" keyword used to mark such lists. Ian -- You received this message because you are subscribed to t

Re: [go-nuts] GIL for Go

2021-04-01 Thread Eric S. Raymond
Amnon : > An exciting announcement from the Go team this morning! PK, that was a pretty good AFJ. You actually achieved weak level 2 on me. Explanation of level 2 (and others) here: http://esr.ibiblio.org/?p=3084 -- http://www.catb.org/~esr/";>Eric S. Raymond -- You received

[go-nuts] Re: Alternate implementations of regular expression matching?

2021-04-01 Thread Doug
You can try my regexp2 engine that's based on the .NET engine: https://github.com/dlclark/regexp2 It supports atomic groups, has no dependencies, and doesn't need cgo. Unfortunately it doesn't support Possessive Quantifier syntax, but supposedly that may be serving as syntactic sugar for atomic