Re: [go-nuts] weird sighup

2020-05-19 Thread Ian Lance Taylor
On Tue, May 19, 2020 at 7:53 PM Adrian Ratnapala wrote: > > I'd have expected that to work, because syntactically the slice is > assigned to only after the new, smaller slice is fully constructed -- > including all the data copying. But it still make me twitchy about > the possibility that the

Re: [go-nuts] weird sighup

2020-05-19 Thread Adrian Ratnapala
I'd have expected that to work, because syntactically the slice is assigned to only after the new, smaller slice is fully constructed -- including all the data copying. But it still make me twitchy about the possibility that the runtime shortens the slice before reading all the data, resulting in

Re: [go-nuts] weird sighup

2020-05-19 Thread Ian Lance Taylor
On Tue, May 19, 2020 at 9:53 AM wrote: > > I am using go-1.14.1. I am using this code to remove i-th element from the > slice. > > s = append(s[:i], s[i+1:]...) > > It works on my machine but gives panic on docker-container with error "range > out of bound" when it has just 1 element left. > >

Re: [go-nuts] DNS lookup timeouts could return net.DNSError instead of poll.TimeoutError

2020-05-19 Thread Ian Lance Taylor
On Tue, May 19, 2020 at 4:27 PM wrote: > > I get DNS lookup timeouts many times a day when running Go HTTP clients on > Kubernetes, where UDP packets are sometimes dropped due to a race condition > in the Linux kernel. I'd like to propose a small standard library change to > help debug these

[go-nuts] DNS lookup timeouts could return net.DNSError instead of poll.TimeoutError

2020-05-19 Thread therealmarkhale
Hi, I get DNS lookup timeouts many times a day when running Go HTTP clients on Kubernetes, where UDP packets are sometimes dropped due to a race condition in the Linux kernel. I'd like to propose a small standard library change to help debug these scenarios and get some feedback on the idea

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread mike
As Michael Jones said, you still need to play by the testing package's benchmark rules for it to be able to benchmark your code. So something along these lines. func BenchmarkMarshalSample(b *testing.B) { for i:=0; i < b.N; i++ { var sum int64 // start := time.Now()

[go-nuts] Re: Client certificate not sent to server

2020-05-19 Thread Mark Petrovic
I know this is an old thread, but I found it, so others might, too. I struggled with a similar problem of the Go HTTP client not sending client certs when challenged by the server. Yet, curl worked fine when given the same client certs, calling the same server endpoint. The cert chains I

Re: [go-nuts] golang protobuf, struct copy problem

2020-05-19 Thread Vasiliy Tolstov
пт, 8 мая 2020 г. в 22:22, Robert Engels : > > Have the compute struct contain the proto struct. > I think that question is more about how to copy fields from one struct to another. For example one struct contains some tags (for example to work with some db orm), and proto struct don't have such

[go-nuts] Re: Sscanf() skip elements

2020-05-19 Thread 'simon place' via golang-nuts
obviously, you could do this... https://play.golang.org/p/isqA3N0LBkn or better?... https://play.golang.org/p/8hXgZqBNyns On Friday, 10 April 2020 18:17:53 UTC+1, Daniel Gorbe wrote: > > Hi! > > > It is possible to skip elements of a string with Sscanf()? As in C with > *%*s.* > > Example: > >

Re: [go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Marvin Renich
* Warren Bare [200519 13:53]: > OK, I added a sum of the rand to the demo code and the results are the > same. Since it is displaying the sum, it seems clear that the code is not > optimized away. > > Again, I am NOT trying to time each iteration of the loop. This is a > minimal

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Warren Bare
OK, I got it. You were trying to change the code I was benchmarking, and I did not realize you were trying to say a benchmark must have the ability to run b.N times. Yes, that was the problem. This fixed it: func BenchmarkMarshalSample(b *testing.B) { var sum int64 for i:= 0; i <

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Warren Bare
OK, I added a sum of the rand to the demo code and the results are the same. Since it is displaying the sum, it seems clear that the code is not optimized away. Again, I am NOT trying to time each iteration of the loop. This is a minimal demonstration of a weirdness I was seeing in my own

Re: [go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Michael Jones
as was explained, the loop needs to be "for i:=0; i < b.N; i++" as was mentioned, the compiler's dead code elimination efforts can frustrate benchmarking. they way to make sure the test code survives is to not let it be dead code. for example // external var dummy func for i:=0; i < b.N; i++ {

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Warren Bare
>You are supposed to run the loop b.N times, not some fixed constant. I understand. This is a simulation of a single bigger task that takes a while. I'm not trying to time the rand function inside the loop. The loop is simply to burn time. This simple function is a minimal example that

[go-nuts] weird sighup

2020-05-19 Thread anderson . mill . road
Hi, I am using go-1.14.1. I am using this code to remove i-th element from the slice. s = append(s[:i], s[i+1:]...) It works on my machine but gives panic on docker-container with error "range out of bound" when it has just 1 element left. I want to check if this is an unsafe code and how

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Volker Dobler
You are supposed to run the loop b.N times, not some fixed constant. Also make sure the compiler doesn't optimize away the whole function. V. On Tuesday, 19 May 2020 18:20:43 UTC+2, Warren Bare wrote: > > Hi Folks, > > I'm getting weird results from Benchmark. Maybe someone can help me >

[go-nuts] help understanding weird Benchmark results

2020-05-19 Thread Warren Bare
Hi Folks, I'm getting weird results from Benchmark. Maybe someone can help me understand this. I'm running on amd-64 (Threadripper 16 core 32 thread) Windows 10. Go 1.14.3 I have the benchmark below (main_test.go) on a minimum "hello world" main.go (just like playground). When I run the

[go-nuts] Re: How to work with multiple environment like dev, test, staging, prod in golang ?

2020-05-19 Thread Ronny Bangsund
On Sunday, May 17, 2020 at 7:19:23 PM UTC+2, Shishira Pradhan wrote: > > In springboot, we have configuration like port, database etc info are > stored in yaml files like application-dev.yml, application-test.yml, > application-prod.yml profiles, and profile name is passed during running >

[go-nuts] How to dump cfg for method ?

2020-05-19 Thread eric fang
How to generate the cfg of the following Replace method ? I used this command "GOSSAFUNC=Replace:* go tool compile main.go" but it doesn't work. Thanks. package main type byteReplacer [256]byte func (r *byteReplacer) Replace(s string) string { var buf []byte // lazily allocated