Re: [go-nuts] WIKI: Assert Libraries for Testing

2022-01-12 Thread Romenigue Thier
Thanks @kortschak! I understand your concerns, I work on the "both sides" too. The code (test) should be readable, easy to understand and a simple assertion can be more "clean way" that a long conditional if. A "ugly test" can be created with or without an assertion library. The concern about

Re: [go-nuts] WIKI: Assert Libraries for Testing

2022-01-12 Thread 'Dan Kortschak' via golang-nuts
I have thoughts about the impact of assertion libraries in software engineering. I came from a background where they are commonplace into Go and in my earlier projects I used some the earlier iterations on them (go-check). While it's true that developers *can* use assertion libraries to provide ri

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread E Z
ctx.Err() really simplifies the whole process. I'll use it to optimize my task executor, thanks. On Wednesday, 12 January 2022 at 10:05:57 UTC Brian Candler wrote: > >> On Wednesday, 12 January 2022 at 08:41:23 UTC lege...@gmail.com wrote: >> >>> What I think it's not so good is that I must add t

Re: [go-nuts] Jobs

2022-01-12 Thread Yamadaえりな
Linkedin, facebook, or this similar one? https://golang.cafe/ ありがとう On Thu, Jan 13, 2022 at 2:45 AM Alex Dvoretskiy wrote: > What is a good way to find Go developers and Go jobs nowadays? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group.

Re: [go-nuts] profiling help

2022-01-12 Thread Steve Roth
Thanks, Kurtis, The production version of this code runs as a regular web server. I was profiling in CGI just to simplify the configuration. Regards, Steve On Wed, Jan 12, 2022 at 5:34 PM Kurtis Rader wrote: > FWIW, I had the same suspicion as Robert. In my experience a CGI task that > takes

Re: [go-nuts] profiling help

2022-01-12 Thread Kurtis Rader
FWIW, I had the same suspicion as Robert. In my experience a CGI task that takes less than, say, 200ms is going to be swamped by startup costs. It's usually better to use the FastCGI protocol

Re: [go-nuts] profiling help

2022-01-12 Thread Steve Roth
Hi, Robert, The request *should* be super short, but it was actually taking 2.5 seconds. That was the whole reason I started trying to profile it, to figure out why a simple request was taking so long. Ian's suggestion of heap tracing found the issue for me: there was an unexpected allocation o

Re: [go-nuts] profiling help

2022-01-12 Thread robert engels
Are you certain that the requests aren’t super short - so all you are measuring is the runtime startup time / and the overhead of parsing the CGI “protocol". This is not insignificant. CGI really only works well for long requests IMO. > On Jan 12, 2022, at 5:29 PM, Steve Roth wrote: > > Thank

Re: [go-nuts] profiling help

2022-01-12 Thread Steve Roth
Thank you, Ian. From the function names, I suspected that the 70% chain was the garbage collector. But in this run, garbage collection was turned off with GOGC=off, and that was verified with GODEBUG=gctrace=1. So I thought perhaps they must be something else. I will proceed with heap profiling

[go-nuts] WIKI: Assert Libraries for Testing

2022-01-12 Thread Romenigue Thier
Hello! Recently I learn the page TestComments on Golang Wiki (on Github). The section about Assert Libraries discourage the use of them. But I guess there's a little bit mistake

Re: [go-nuts] profiling help

2022-01-12 Thread Ian Lance Taylor
On Wed, Jan 12, 2022 at 1:54 PM Steve Roth wrote: > > I am attempting to profile my code, and I'm unable to interpret the results. > So first, the meta-question is, what's the best forum to use to request help > with such things? This is a good place. See also https://golang.org/wiki/Question

[go-nuts] Re: profiling help

2022-01-12 Thread Howard C. Shaw III
The 17% is sleeping. The 70% is garbage collection. On Wednesday, January 12, 2022 at 3:54:32 PM UTC-6 st...@rothskeller.net wrote: > I am attempting to profile my code, and I'm unable to interpret the > results. So first, the meta-question is, what's the best forum to use to > request help w

[go-nuts] profiling help

2022-01-12 Thread Steve Roth
I am attempting to profile my code, and I'm unable to interpret the results. So first, the meta-question is, what's the best forum to use to request help with such things? The code I'm profiling is the server side of a moderately complex webapp. For simplicity, I've wrapped it with net/http/cgi a

Re: [go-nuts] Fatal error : on running go vet cmd

2022-01-12 Thread Ian Lance Taylor
On Wed, Jan 12, 2022 at 1:17 PM Tejas Gowda wrote: > > I am using linux enviorment, installed go 1.6 1.16 rather than 1.6, I hope. What Linux distro? Ian > On Thursday, January 13, 2022 at 2:29:00 AM UTC+5:30 Ian Lance Taylor wrote: >> >> On Wed, Jan 12, 2022 at 10:58 AM Tejas Gowda wrote: >>

Re: [go-nuts] Fatal error : on running go vet cmd

2022-01-12 Thread Tejas Gowda
I am using linux enviorment, installed go 1.6 On Thursday, January 13, 2022 at 2:29:00 AM UTC+5:30 Ian Lance Taylor wrote: > On Wed, Jan 12, 2022 at 10:58 AM Tejas Gowda wrote: > > > > # runtime/cgo > > _cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory > > #include > > ^ > >

Re: [go-nuts] Fatal error : on running go vet cmd

2022-01-12 Thread Ian Lance Taylor
On Wed, Jan 12, 2022 at 10:58 AM Tejas Gowda wrote: > > # runtime/cgo > _cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory > #include > ^ > compilation terminated. That looks like you have a C compiler installed but no C library installed. Hard to say more

Re: [go-nuts] Convert a go.mod file into checked out dependencies

2022-01-12 Thread 'Dan Kortschak' via golang-nuts
While not a tool, there is code that can be bent to this in golang.org/x/pkgsite/internal/source. I used that to get repo information for a tool to obtain homepage and issue page links from Go executables[1]. You could easily extend that kind of approach to get the actual repo at the relevant versi

Re: [go-nuts] Convert a go.mod file into checked out dependencies

2022-01-12 Thread Kevin Burke
Ah, yes, that would work but wouldn't include the git history... On Wednesday, January 12, 2022 at 12:28:49 PM UTC-8 robert...@gmail.com wrote: > https://go.dev/ref/mod#go-mod-vendor > > On Wed, Jan 12, 2022 at 10:58 AM Kevin Burke wrote: > >> Hi, >> Sometimes I just want to inspect third part

Re: [go-nuts] Convert a go.mod file into checked out dependencies

2022-01-12 Thread Robert Dionne
https://go.dev/ref/mod#go-mod-vendor On Wed, Jan 12, 2022 at 10:58 AM Kevin Burke wrote: > Hi, > Sometimes I just want to inspect third party code for a library, and/or > edit it. > > I'm looking for a tool that will read all of the dependencies in a go.mod > file and then check out all of the r

[go-nuts] Fatal error : on running go vet cmd

2022-01-12 Thread Tejas Gowda
# runtime/cgo _cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory #include ^ compilation terminated. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails f

[go-nuts] Convert a go.mod file into checked out dependencies

2022-01-12 Thread Kevin Burke
Hi, Sometimes I just want to inspect third party code for a library, and/or edit it. I'm looking for a tool that will read all of the dependencies in a go.mod file and then check out all of the right versions of all of the source code into the right places in a $GOPATH. Does that exist? Fail

[go-nuts] Jobs

2022-01-12 Thread Alex Dvoretskiy
What is a good way to find Go developers and Go jobs nowadays? -- 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 t

Re: [go-nuts] Golang JSONObject

2022-01-12 Thread Shulhan
On Wed, 22 Dec 2021 23:55:43 -0800 (PST) A JI wrote: > Why, when the object of struct is lowercase. I can't fill it and > convert to JSON ? > > https://go.dev/play/p/WZCvC7M5YAp > Is not the object of struct that affect the output of JSON, but the name of field. If the name of field start wit

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread David Finkel
On Wed, Jan 12, 2022 at 5:02 AM Tobias Klausmann wrote > So what is the *idiomatic* way of being able to use `continue` (or > something like it), yet have "always do this" code at the end of the > loop? As I understand it, `defer` only works for ends of functions, not > ends of blocks, and label

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! On Wed, 12 Jan 2022, Rob Pike wrote: > What's wrong with >for ;; time.Sleep(delay) { ... } > ? > > This technique is as old as the hills. Or at least as old as C for loops. Never been a C guy :) Thanks, that works perfectly! Best, Tobias -- You received this message because you are s

Re: [go-nuts] Looping and tail-end code

2022-01-12 Thread Rob Pike
What's wrong with for ;; time.Sleep(delay) { ... } ? This technique is as old as the hills. Or at least as old as C for loops. -rob On Wed, Jan 12, 2022 at 9:02 PM Tobias Klausmann wrote: > > Hi! > > Often with tools that poll something, you get code of this form: > > ``` > for { >

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread Brian Candler
Based on this stackoverflow answer : - package main import ( "context" "fmt" "net" "time" ) const DNS_SERVER = "1.2.3.4:53" const TIMEOUT = 3 * time.Second func main() {

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread 'Axel Wagner' via golang-nuts
On Wed, Jan 12, 2022 at 11:03 AM jan.f...@gmail.com wrote: > Just a related observation. I don't think you need to have a select > statement to check if a context is cancelled. I think it is sufficient to > just check if ctx.Err() gives a result different from nil. > I believe you are right, the

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread Brian Candler
On Wednesday, 12 January 2022 at 08:41:23 UTC lege...@gmail.com wrote: > What I think it's not so good is that I must add the select at all the > places the goroutine is waiting or looping > I don't think you do. Well-behaved functions which take a Context will return with an error if the cont

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread jan.f...@gmail.com
Just a related observation. I don't think you need to have a select statement to check if a context is cancelled. I think it is sufficient to just check if ctx.Err() gives a result different from nil. >From the API documentation for Context (https://pkg.go.dev/context#Context): // If Done is not

[go-nuts] Looping and tail-end code

2022-01-12 Thread Tobias Klausmann
Hi! Often with tools that poll something, you get code of this form: ``` for { r, err := doSomeCall() if err != nil { log.Printf("Some error:", err) continue } s, err := doSomeOtherCall(r) if err != nil { log.Printf(

Re: [go-nuts] Any good idea to stop the goroutine as soon as possible?

2022-01-12 Thread E Z
Hi Axel, thank you very much, your explanation of this problem is very detailed and solves my question. What I think it's not so good is that I must add the select at all the places the goroutine is waiting or looping, it makes the execution and scheduling part of the task scheduling system coupli