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

2022-09-19 Thread Kurtis Rader
Insufficient information. It looks like your question involves handling
JSON data structures but beyond that no one is going to be able to provide
any useful advice. Can you provide a small code example for what you
have tried? Can you elaborate on what you mean by "in response"? Are you
making a HTTP request that returns JSON and you are having trouble parsing
the result into equivalent Go data structures?

On Mon, Sep 19, 2022 at 7:01 PM Vick Vicky  wrote:

> 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/5b5c1c8a-6777-4e18-82b2-c4be03576466n%40googlegroups.com
> 
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD_JU5gZ%3DG5pN4a%3D%3DYO98g7CWhfem7OZ7JcM4h_-%3DH7PVw%40mail.gmail.com.


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

2022-09-19 Thread Josh Peterson


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/fd5a1ad8-cb17-4667-9e32-8f60e6433923n%40googlegroups.com.


[go-nuts] Get array response back in golang

2022-09-19 Thread Vick Vicky
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/5b5c1c8a-6777-4e18-82b2-c4be03576466n%40googlegroups.com.


[go-nuts] Re: Getting 410 error from https://sum.golang.org/lookup/github.com for a private github repo

2022-09-19 Thread Yoon Sean
Thank you very much.
You save me from this issue.

2020년 5월 28일 목요일 오전 10시 46분 28초 UTC+7에 ghost.m...@gmail.com님이 작성:

> You may try: 
>
> export *GONOSUMDB*="github.com/mycompany/*,github.com/secret/*"
>
> to disable sum check for some libraries. But try **not** to do this:
>
> > $export GOSUMDB=off
>
> or you may face security issue.
>

-- 
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/e2f50849-a8c6-45d2-93c0-389ca3657f6dn%40googlegroups.com.


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

2022-09-19 Thread TECHAX
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+unsubscr...@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/CAEMj0xp0G6LDWAB%2BJu7%3DPUXhH3T-%3DRPAmTN%2B_zZGkWoY7sjOjA%40mail.gmail.com.


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

2022-09-19 Thread Tamás Gulácsi
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+unsubscr...@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.


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

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 2:52 PM Amnon  wrote:

> What happens if the user enters the string "'; rm -fr ~;'" ?

https://twitter.com/codepo8/status/1373224835866882048

-- 
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-UGc%2BGqd3V1FzePvB745zB1puMoNwoX-UJeJM6wJu_31Q%40mail.gmail.com.


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

2022-09-19 Thread Amnon
What happens if the user enters the string "'; rm -fr ~;'" ?

On Monday, 19 September 2022 at 13:25:31 UTC+1 Brian Candler wrote:

> On Monday, 19 September 2022 at 10:50:36 UTC+1 princ...@gmail.com wrote:
>
>>
>> *search:=scanner.Text()cmd1,err:=exec.Command("bash", "-c", "find . -name 
>> '*$search*'")*
>
>
> You first "search" is a go local variable.
> Your second "$search" is seen by the shell as a reference to an 
> environment variable.
>
> So if you want to do it that way, you need to set it in the environment, 
> e.g. with os.Setenv.
> https://pkg.go.dev/os#Setenv
>

-- 
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/e2aafbd7-3f67-4170-aee1-489cf8c26540n%40googlegroups.com.


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

2022-09-19 Thread Brian Candler
On Monday, 19 September 2022 at 10:50:36 UTC+1 princ...@gmail.com wrote:

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


You first "search" is a go local variable.
Your second "$search" is seen by the shell as a reference to an environment 
variable.

So if you want to do it that way, you need to set it in the environment, 
e.g. with os.Setenv.
https://pkg.go.dev/os#Setenv

-- 
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/f7a8dc06-7c2e-4756-9082-d28460eab1den%40googlegroups.com.


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

2022-09-19 Thread PK
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/af021af3-6521-470a-a813-d6977e9bf823n%40googlegroups.com.


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

2022-09-19 Thread Jan Mercl
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-Up7L%2B%3D%3DcRSftkwvn7VBWDLmpsJmeY%2B8TVTkfzjnd-JMQ%40mail.gmail.com.


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

2022-09-19 Thread PK
HI everyone, can anyone help me with this:
I want to list all the files having some user's entered string as substring 
in their name.
So I wrote these commands:





*scanner := bufio.NewScanner(os.Stdin)fmt.Println("Enter the substring 
name")scanner.Scan()search:=scanner.Text()cmd1,err:=exec.Command("bash", 
"-c", "find . -name '*$search*'")*

But I think the variable search is not getting used inside exec command.

Can anyone please let me know, how I can use the golang variable in bash 
command this?

Thanks

-- 
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/3f74da22-624c-4aa9-abc6-9d61943c1c82n%40googlegroups.com.