[go-nuts] Re: regex extract with group

2022-09-20 Thread Brian Candler
Can you show your Go code, including the failing test data?  Using 
https://go.dev/play/ is best.

If you're using the built-in re2 library, its regular expressions are 
documented here: https://github.com/google/re2/wiki/Syntax

Not all regular expression libraries are the same, and this table also 
includes some variations which are supported by other popular RE libraries, 
but *not* by re2.

Note in particular the section headed "Grouping", and the way you need to 
define named capture groups:

(?Pre)
named & numbered capturing group (submatch)

(?re)
named & numbered capturing group (submatch) (NOT SUPPORTED)

On Tuesday, 20 September 2022 at 20:04:00 UTC+1 khalid@gmail.com wrote:

> I have this code working in nodejs but I am unable to make it work in 
> golang.
>
> const regex = /Street name: (?[^\r\n]+)\s+House number: 
> (?[^\r\n]+)\s+City: (?[^\r\n]+)\s+State: 
> (?[^\r\n]+)\s+Postal code: (?[^\r\n]+)\s+Country: 
> (?[^\r\n]+)/
>
> var funstring = "Street name: Main St\r\nHouse number: 3250\r\nCity: 
> Corona\r\nState: CA\r\nPostal code: 92882\r\nCountry: United States";
> var addgroup = funstring.match(new RegExp(regex))
> console.log(add.groups.street) //give me "Main St"
>
> Can someone help, my regex is failing in golang
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/231424c7-10cf-4034-af7c-efd3766d7a4dn%40googlegroups.com.


[go-nuts] regex extract with group

2022-09-20 Thread Khalid Ansari
I have this code working in nodejs but I am unable to make it work in 
golang.

const regex = /Street name: (?[^\r\n]+)\s+House number: 
(?[^\r\n]+)\s+City: (?[^\r\n]+)\s+State: 
(?[^\r\n]+)\s+Postal code: (?[^\r\n]+)\s+Country: 
(?[^\r\n]+)/

var funstring = "Street name: Main St\r\nHouse number: 3250\r\nCity: 
Corona\r\nState: CA\r\nPostal code: 92882\r\nCountry: United States";
var addgroup = funstring.match(new RegExp(regex))
console.log(add.groups.street) //give me "Main St"

Can someone help, my regex is failing in golang

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/af9b91ff-16b9-4881-b974-ce3291dafc4dn%40googlegroups.com.


Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread Josh Peterson
Hi Peter,

Please note that versions devel *go1.20-bcd44b61d3*, *1.19.1*, and *1.18.6* 
show times in the *4xxx ns/op* range for *BenchmarkSliceOfArray* while all 
the versions of *1.19* and *1.18* show times in the *2xxx ns/op* range. 

As noted earlier in this thread, the regression is seen on *ARM64* and not 
*AMD64*.

This time I have only included only results for *BenchmarkSliceOfArray*. 
The benchmarks for *BenchmarkSliceOfInt* do not exhibit regression. 

go version *devel go1.20-bcd44b61d3* Tue Sep 20 16:21:31 2022 + 
darwin/arm64
BenchmarkSliceOfArray 262800  *4552* ns/op   16384 
B/op  1 allocs/op
go version *go1.19.1* darwin/arm64
BenchmarkSliceOfArray 229941  *4607* ns/op   16384 
B/op  1 allocs/op
go version *go1.19* darwin/arm64
BenchmarkSliceOfArray 449023  *2580* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.6* darwin/arm64
BenchmarkSliceOfArray 239430  *4377* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.5* darwin/arm64
BenchmarkSliceOfArray 506563  *2349* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.4* darwin/arm64
BenchmarkSliceOfArray 508051  *2362* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.3* darwin/arm64
BenchmarkSliceOfArray 431294  *2357* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.2* darwin/arm64
BenchmarkSliceOfArray 425918  *2715* ns/op   16384 
B/op  1 allocs/op
go version *go1.18.1* darwin/arm64
BenchmarkSliceOfArray 434580  *2351* ns/op   16384 
B/op  1 allocs/op
go version *go1.18* darwin/arm64
BenchmarkSliceOfArray 415366  *2482* ns/op   16384 
B/op  1 allocs/op


On Tuesday, September 20, 2022 at 12:53:40 PM UTC-4 peterGo wrote:

> Jan,
>
> An obvious typo. Read my original message: "I am unable to reproduce your 
> results on AMD64" 
>
> peter
>
> On Tuesday, September 20, 2022 at 12:14:32 PM UTC-4 Jan Mercl wrote:
>
>> On Tue, Sep 20, 2022 at 6:02 PM peterGo  wrote:
>>
>> > Yes, I read that too. A fundamental tenet of science is 
>> reproducibility. I was able to reproduce the AMD64 results and documented 
>> it. A step forward.
>>
>> 5:24 PM (45 minutes ago) > I am unable to reproduce your results on AMD64.
>> 6:02 PM (7 minutes ago) > I was able to reproduce the AMD64 results
>> and documented it.
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7a9b8be8-7f8a-48ac-81ab-24c0780009d9n%40googlegroups.com.


Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread peterGo
Jan,

An obvious typo. Read my original message: "I am unable to reproduce your 
results on AMD64" 

peter

On Tuesday, September 20, 2022 at 12:14:32 PM UTC-4 Jan Mercl wrote:

> On Tue, Sep 20, 2022 at 6:02 PM peterGo  wrote:
>
> > Yes, I read that too. A fundamental tenet of science is reproducibility. 
> I was able to reproduce the AMD64 results and documented it. A step forward.
>
> 5:24 PM (45 minutes ago) > I am unable to reproduce your results on AMD64.
> 6:02 PM (7 minutes ago) > I was able to reproduce the AMD64 results
> and documented it.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/348a4b1d-da1f-4ab9-86e3-1bde022718d5n%40googlegroups.com.


Re: [go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread Jan Mercl
On Tue, Sep 20, 2022 at 6:02 PM peterGo  wrote:

> Yes, I read that too. A fundamental tenet of science is reproducibility. I 
> was able to reproduce the AMD64 results and documented it. A step forward.

5:24 PM (45 minutes ago) > I am unable to reproduce your results on AMD64.
6:02 PM (7 minutes ago) > I was able to reproduce the AMD64 results
and documented it.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-W3MPpt4ifmgD76kiaMRBHvS-j5ohpcbiYVM3HE_6sA4g%40mail.gmail.com.


[go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread peterGo
Brian,

Yes, I read that too. A fundamental tenet of science is reproducibility. I 
was able to reproduce the AMD64 results and documented it. A step forward.

peter

On Tuesday, September 20, 2022 at 11:35:58 AM UTC-4 Brian Candler wrote:

> On Tuesday, 20 September 2022 at 16:24:41 UTC+1 peterGo wrote:
>
>> I am unable to reproduce your results on AMD64. I don't see any 
>> regression.
>
>
> That's expected: the original post also said "I don't see the [...] the 
> perfromance degradation on AMD64". The report is specific to ARM64.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fd9e4d76-6aea-4e20-bd6b-aa6470f7bed3n%40googlegroups.com.


[go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread Brian Candler
On Tuesday, 20 September 2022 at 16:24:41 UTC+1 peterGo wrote:

> I am unable to reproduce your results on AMD64. I don't see any regression.


That's expected: the original post also said "I don't see the [...] the 
perfromance degradation on AMD64". The report is specific to ARM64.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f761d4d5-73c3-4d35-bf86-eb568223743dn%40googlegroups.com.


[go-nuts] Re: Question on 'cmd/compile: handle partially overlapping assignments' behavior on ARM64.

2022-09-20 Thread peterGo
I am unable to reproduce your results on AMD64. I don't see any regression.

Run your benchmarks with option -benchmem.

Version: devel go1.20-1eeb257b88 Tue Sep 20 02:58:09 2022 +
Sizeof(Array{}): 16
Sizeof(int(0)): 8
goarch: amd64
BenchmarkSliceOfInt-4391646  2583 ns/op   8192 B/op  1 allocs/op
BenchmarkSliceOfArray-4  236977  4869 ns/op  16384 B/op  1 allocs/op

Version: go1.17.13
Sizeof(Array{}): 16
Sizeof(int(0)): 8
goarch: amd64
BenchmarkSliceOfInt-4426343  2383 ns/op   8192 B/op  1 allocs/op
BenchmarkSliceOfArray-4  233817  4771 ns/op  16384 B/op  1 allocs/op

The difference is type int is 8 bytes and type [2]int (type Array) is 16 
bytes.

Change the type of Array to 8 bytes (type [1]int).

Version: devel go1.20-1eeb257b88 Tue Sep 20 02:58:09 2022 +
Sizeof(Array{}): 8
Sizeof(int(0)): 8
goarch: amd64
BenchmarkSliceOfInt-4405793  2562 ns/op  8192 B/op  1 allocs/op
BenchmarkSliceOfArray-4  46  2540 ns/op  8192 B/op  1 allocs/op

Version: go1.17.13
Sizeof(Array{}): 8
Sizeof(int(0)): 8
goarch: amd64
BenchmarkSliceOfInt-4440340  2378 ns/op  8192 B/op  1 allocs/op
BenchmarkSliceOfArray-4  481071  2400 ns/op  8192 B/op  1 allocs/op

There is no significant difference.

peter

On Monday, September 19, 2022 at 10:01:37 PM UTC-4 jpsw...@gmail.com wrote:

> I stumbled across a performance regression on ARM64 for go 1.18.6 and 
> 1.19.1 that wasn't present in earlier releases. In the following benchmark, 
> you can see `BenchmarkSliceOfArray` experiences a 70% increase in 
>
> execution time while `BenchmarkSliceOfInt` remains unchanged. 
>
>
> BenchmarkSliceOfArray 413121 2855 ns/op
>
> BenchmarkSliceOfArray 216478 4881 ns/op
>
>
> Through the use of `pprof` and `GOSSAFUNC go build`, it was observed that 
> the latest release employs `runtime.memmove` and accounts for the change in 
> performance. I don't see the invocation of `memmove` or the perfromance 
> degradation on AMD64.
>
>
> I believe this can be traced back to - 
> https://go-review.googlesource.com/c/go/+/425234. 
>
>
> Is this new behavior in this scenario correct or unindented? 
>
>
> Should I open an issue for this? 
>
>
> I am a newbie, so forgive me if there are errors in my approach. 
>
>
> 
>
> go version go1.19 darwin/arm64
>
> % GOMAXPROCS=1 go1.19 test -cpuprofile cpu.prof -bench .  
>
> goos: darwin
>
> goarch: arm64
>
> pkg: foo/bar
>
> BenchmarkSliceOfInt 572226 2066 ns/op
>
> BenchmarkSliceOfArray 413121 2855 ns/op
>
> PASS
>
> ok foo/bar 3.488s
>
> 
>
> go version go1.19.1 darwin/arm64
>
> % GOMAXPROCS=1 go test -cpuprofile cpu.prof -bench .   
>
> goos: darwin
>
> goarch: arm64
>
> pkg: foo/bar
>
> BenchmarkSliceOfInt 527084 2065 ns/op
>
> BenchmarkSliceOfArray 216478 4881 ns/op
>
> PASS
>
> ok foo/bar 2.468s
>
> ok foo/bar 3.538s
>
> 
>
> package datamove
>
>
> type Array [2]int
>
>
> func moveSliceOfArrayData(s []Array) []Array {
>
> for i := 1; i < len(s); i++ {
>
> s[i-1], s[i] = s[i], s[i-1]
>
> }
>
> return s
>
> }
>
>
> func moveSliceOfIntData(s []int) []int {
>
> for i := 1; i < len(s); i++ {
>
> s[i-1], s[i] = s[i], s[i-1]
>
> }
>
> return s
>
> }
>
> 
>
> package datamove
>
>
> import (
>
> "testing"
>
> )
>
>
> var resultInt []int
>
> var resultArray []Array
>
>
> func BenchmarkSliceOfInt(b *testing.B) {
>
> var r []int
>
> for n := 0; n < b.N; n++ {
>
> s := make([]int, 1000)
>
> r = moveSliceOfIntData(s)
>
> }
>
> resultInt = r
>
> }
>
>
> func BenchmarkSliceOfArray(b *testing.B) {
>
> var r []Array
>
> for n := 0; n < b.N; n++ {
>
> s := make([]Array, 1000)
>
> r = moveSliceOfArrayData(s)
>
> }
>
> resultArray = r
>
> }
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/73f49ef0-5e4e-4bb8-9976-534894ffde38n%40googlegroups.com.


[go-nuts] Labeled property graphs and embedded openCypher library

2022-09-20 Thread burak serdar
I would like to announce two open-source Go libraries we have been working
on:

Labeled Property Graphs: https://github.com/cloudprivacylabs/lpg

This library supports openCypher (Neo4j) style of labeled property graphs
in memory. That is:
  * Nodes have a set of labels, and a set of key-values,
  * Edges are directed, each edge has a label and a set of key-values.
It also includes a JSON serialization for labeled property graphs.

The API is stable, and it performs well.

Embedded openCypher implementation:
https://github.com/cloudprivacylabs/opencypher

openCypher is a query language for labeled property graphs (
https://opencypher.org/). This library provides support for the openCypher
language. It allows running statements to create, modify, and query graphs
in memory.

This library is still being developed, but functional (with the exception
of multi-part queries and some other features that will be added in time).

Both libraries are part of a larger semantic interoperability framework,
the Layered Schema Architecture. They are being used in a federally funded
data harmonization project for health data:
https://github.com/cloudprivacylabs/leap-sh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2Rqr8zR6OD6wHDyCLpP3q_md7hD3dve1NSsobebQm9V4rpA%40mail.gmail.com.


[go-nuts] Re: Get array response back in golang

2022-09-20 Thread Wissem belg
This is not an array.. this is a map that contains arrays.. You can get 
this JSON by marshelling an object of type map[string][]string

Le mardi 20 septembre 2022 à 04:01:33 UTC+2, Vick Vicky a écrit :

> hey there!
> how i can get array in response e.g
> {
> "make":["Toyota","Honda"]
> "model":[1992,2001,]
> "year":[2021,2012]
> }
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2d812a1f-7307-4fbf-80ce-6815c05b2fcen%40googlegroups.com.


Re: [go-nuts] Using golang variable in bash script Command

2022-09-20 Thread Robert Solomon
I've done this for Linux and windows, as I regularly use both.  But I used 
a different strategy.  I used the os functions to retrieve a slice of 
strings that I can then filter and sort as I desire.  And I use the command 
line to get the target string.

github.com/drrob1/src/dsrt
also in that repo is ds and rex that do this. dsrtr and dsrtre search all 
subdirectories down from the current dir for what you describe.
And I also sort the returned list by time w/ the most recent first.
--rob solomon

On Monday, September 19, 2022 at 12:08:24 PM UTC-4 princ...@gmail.com wrote:

> Thank you for the response.
>
> On Mon, Sep 19, 2022 at 8:26 PM Tamás Gulácsi  wrote:
>
>> No, please, no!
>>
>> Do NOT use bash with string interpolation if possible!
>> Call find directly:
>> *cmd, err := exec.Command("find", ".", "-name", search)*
>> princ...@gmail.com a következőt írta (2022. szeptember 19., hétfő, 
>> 12:04:32 UTC+2):
>>
>>> then we don't need to add these commands 
>>>
>>>
>>>
>>> *scanner := bufio.NewScanner(os.Stdin)fmt.Println("Enter the substring 
>>> name")scanner.Scan()search:=scanner.Text()*
>>>  right???
>>>
>>> we only need to keep this one
>>>  *cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . -name %s", 
>>> search))*
>>>
>>> On Monday, September 19, 2022 at 3:31:12 PM UTC+5:30 Jan Mercl wrote:
>>>
 On Mon, Sep 19, 2022 at 11:50 AM PK  wrote:

 > search:=scanner.Text()
 > cmd1,err:=exec.Command("bash", "-c", "find . -name '*$search*'")

 Try something like this, not tested:

 cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . 
 -name %s", search))

 -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/fb987200-6678-443f-a0ab-884b5f77c324n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f1ddd106-82e4-4e90-a585-99f62befda3bn%40googlegroups.com.


Re: [go-nuts] Re: Single Job to Multi Job

2022-09-20 Thread Robert Engels
I think you might find it easier to reason about if you think pull rather than 
push. That is, the client asks the server “do you have a job for me” and the 
server returns the job. If instead as in your design the server pushes the job 
to the client it can get real complex (e.g what if the client isn’t ready). 

Even with the pull you still need to handle errors (e.g the client fails while 
processing a job - what does that and how it is handled and communicated). 

These systems can get complex very quickly - you are probably better off using 
an off the shelf solution (search job/workflow orchestration). 

But if it just for your edification have a crack at it and have fun. 

> On Sep 20, 2022, at 7:09 AM, Peter Galbavy  wrote:
> 
> A good starting point is to look for a multiplxer / multiplexor
> 
>> On Saturday, 17 September 2022 at 11:59:11 UTC+1 ramki...@hotmail.com wrote:
>> I have a tcp server that collects jobs (lets say 10), and tcp clients get 
>> the jobs. This is done in a FIFO method, where the first job the server 
>> gets, all tcp clients get that job. When that job is completed, all tcp 
>> clients get the second job etc etc.
>> 
>> I'm trying to find a way/term (so that I can google template code) on how to 
>> convert this FIFO method to one where it sends (let's say) job 1, 2 and 3 to 
>> three different clients, so that they work on it in parallel.
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/2bc9b736-2ea6-4f9f-bf7a-35a5fe028a8an%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/A0F77899-5C30-4B86-86A4-E90AC3F4DF0E%40ix.netcom.com.


[go-nuts] Re: Single Job to Multi Job

2022-09-20 Thread Peter Galbavy
A good starting point is to look for a multiplxer / multiplexor

On Saturday, 17 September 2022 at 11:59:11 UTC+1 ramki...@hotmail.com wrote:

> I have a tcp server that collects jobs (lets say 10), and tcp clients get 
> the jobs. This is done in a FIFO method, where the first job the server 
> gets, all tcp clients get that job. When that job is completed, all tcp 
> clients get the second job etc etc.
>
> I'm trying to find a way/term (so that I can google template code) on how 
> to convert this FIFO method to one where it sends (let's say) job 1, 2 and 
> 3 to three different clients, so that they work on it in parallel.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2bc9b736-2ea6-4f9f-bf7a-35a5fe028a8an%40googlegroups.com.