Re: [go-nuts] Best way to mark unused parameters/error values reported by linter

2023-03-06 Thread Marcello H
What I do (and is a good practice), is adding behind the comment more info. //nolint:errcheck // no need to test it, because it was tested before with stat Op maandag 6 maart 2023 om 23:05:42 UTC+1 schreef Steven Hartland: > I would use the following if I truly wanted to ignore an error, but I

Re: [go-nuts] HTTP client - streaming POST body?

2023-03-06 Thread Amnon
As Bruno said. Try something like this: func uploadBig(url string ) error { file, err := os.Open("bigfile.txt") if err != nil { return err } defer file.Close() resp, err := http.Post(url, "text/plain", file) if err != nil { return err } defer

Re: [go-nuts] [net/http] How to capture raw client TLS handshake data?

2023-03-06 Thread Eli Lindsey
It’s not currently possible. Some of us run with patches exposing the TLS extensions to support this use case. The relevant GitHub issue is https://github.com/golang/go/issues/32936-eli On Mar 6, 2023, at 2:14 PM, Aurora wrote:Is it possible to capture the whole TLS handshake data coming from a

[go-nuts] [net/http] How to capture raw client TLS handshake data?

2023-03-06 Thread Aurora
Is it possible to capture the whole TLS handshake data coming from a HTTP client request, enough to actually build a JA3 hash out of it? The tls.ClientHelloInfo does apparently give some but not all the parts which are needed to build a JA3 hash. -- You received this message because you are

Re: [go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread 'Axel Wagner' via golang-nuts
No, Go generics do not exist at runtime, so there is no way for this to possibly work in generality. The best you can do is make a function that takes an `any` or a `reflect.Value` and use `reflect` to type-check at runtime, returning an error if type-checking fails:

Re: [go-nuts] Best way to mark unused parameters/error values reported by linter

2023-03-06 Thread Steven Hartland
I would use the following if I truly wanted to ignore an error, but I would question if ignoring the error from os.Open was ever a good idea. If you want to handle a file not found error then do so, don't just ignore the error. file, _ := os.Open(name) //nolint: errcheck On Mon, 6 Mar 2023 at

Re: [go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread Rory Campbell-Lange
On 06/03/23, Bruno Albuquerque (b...@gmail.com) wrote: > You can easily get it to work, but not in a useful way I guess. > > https://go.dev/play/p/mq0O8OhJ1-a > > You could have a different template for each type you use I guess. Thanks for that solution. I guess I could do

Re: [go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread Bruno Albuquerque
You can easily get it to work, but not in a useful way I guess. https://go.dev/play/p/mq0O8OhJ1-a You could have a different template for each type you use I guess. -Bruno On Mon, Mar 6, 2023 at 4:43 PM Rory Campbell-Lange wrote: > Hi. I have a generic function > > func slicerG[A any](s

[go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread Rory Campbell-Lange
Hi. I have a generic function func slicerG[A any](s []A, i int) []A { fmt.Println(len(s), i) if i > len(s) { return s } return s[0:i] } When I try to register this in a template's FuncMap, it fails with "cannot use generic function slicerG

[go-nuts] Best way to mark unused parameters/error values reported by linter

2023-03-06 Thread Sergei Dyshel
Hello all, I'm incorporating golangci-lint linter aggregator in my codebase and facing a dilemma on how to mark false positives for these 2 linters: - errcheck - reports unchecked errors. - unparam - reports unused function parameters. The

Re: [go-nuts] HTTP client - streaming POST body?

2023-03-06 Thread Bruno Albuquerque
The body is just an io.Reader. You just need to write one that materializes and streams the data you want instead of using a buffer with all of it. The entire design is to allow things like what you want to do. :) -Bruno On Mon, Mar 6, 2023 at 10:08 AM 'Jim Smart' via golang-nuts <

[go-nuts] HTTP client - streaming POST body?

2023-03-06 Thread 'Jim Smart' via golang-nuts
Hi all, I'm looking for an HTTP client that allows my code to write the body content down the pipe while doing a POST. The use case here is that I'm wishing to send very large UPDATE/INSERT queries/commands to an HTTP endpoint, and the body content of those queries/commands is actually

[go-nuts] Re: alignment of stack-allocated variables?

2023-03-06 Thread TheDiveO
Keith made me aware of the fact that my benchmark is using the binary.BigEndian interface instead of "unrolling" the interface to use the specific type at runtime. cpu: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz BenchmarkUnsafe-8 10 5.991 ns/op 0 B/op

Re: [go-nuts] Detecting / Avoiding network bottleneck when sending concurrent HTTP requests to many hosts.

2023-03-06 Thread Robert Engels
Have you used netstat to check how many open connections you have? You probably need to forcibly close them so they don’t end up in time wait states. Also, you don’t say what N is? Lastly you will get different errors for a dns or host error than a resources exhausted. If you configure the

[go-nuts] Detecting / Avoiding network bottleneck when sending concurrent HTTP requests to many hosts.

2023-03-06 Thread nohehf
Hi! I'm building a tool that needs to concurrently send request to multiple hosts (for fingerprinting purposes). I'm using github.com/valyala/fasthttp for the client but it works the same with net/http. The main program basically starts n workers and those will take endpoints to scan from a