Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread Vladimir Varankin
> [..] when the method modifies the sruct's members (or just have a sync.Mutex member) >From my experience, these are the major points for defaulting to use the pointer receiver "when in doubt". The difference between "func (t T) Foo" and "func (t *T) Foo", is often too subtle to spot a bug in

[go-nuts] Re: When net package is imported building binary with CGO generate error

2023-11-03 Thread Vladimir Varankin
Hey there, Which OS (Linux distro) you're using? As far as I can see from cgo_linix.go [1], the constants, that trigger an error, should come from the "netdb.h", which comes with libc. [1]: https://github.com/golang/go/blob/go1.19.13/src/net/cgo_linux.go On Thursday, November 2, 2023 at

[go-nuts] Re: Why doesn't the database/sql package in Go support using placeholders "?" to replace the database name and username in SQL statements?

2023-09-18 Thread Vladimir Varankin
A thing, that it may be valuable to explain further, is that Go's "database/sql" doesn't come with a built-in query builder. The package implements the database connection pooling/management, but it passes the user's SQL input and its arguments to the "driver". Depending on the particular

[go-nuts] Re: Why is the reason that the flame graph in go pprof rotated 180 degrees?

2023-06-14 Thread Vladimir Varankin
Hey there, In this issue, back then (https://github.com/google/pprof/issues/359), I linked my interpretation for the reasoning to switch from flame graph to "icicle graph". Just as you wrote, in some (many) cases, the investigations starts from the bottom of the graph, forcing a user to scroll

Re: [go-nuts] Re: Looking for a specialized proxy package

2023-03-16 Thread Vladimir Varankin
Hey Michael, > The piece I'm missing is how to construct a proxying handler that will use the identifier in the link to look up the tunnel port and fetch the IOT's home page and thereafter make it seem as though the user is directly browsing the IOT. If I got the question right, there are two

[go-nuts] Re: Debugging memory leak when a GO process crashed

2023-01-13 Thread Vladimir Varankin
Hey Mariappan, >From my experience, there are several possible options: I believe you can use GOTRACEBACK=crash env variable (or its equivalent in the runtime/debug package in the std) to get a coredump on the crash. See this old post from JBD [1], that explored this. If you clearly observe,

[go-nuts] Re: What happened if http timeout happened but the request is still sent out

2023-01-04 Thread Vladimir Varankin
> If the connection to the server is lost while transmission, you will probably receive a broken pipe error. > If the timeout happens before sending data, nothing to care. > If the timeout happens during data transmission, well, you may have incomplete data(corrupted) in the server. In addition

[go-nuts] Re: Practical use cases of recover in golang

2022-10-10 Thread Vladimir Varankin
One particular example is if you use std's net/http server, you (indirectly) use recover. The std's documentation for the Handler interface has a section, where they outline how the server recovers from a panic, that fired in the context of a request https://pkg.go.dev/net/http#Handler On

[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-29 Thread Vladimir Varankin
Hey there, > I took runtime/cpuprof.go with version 1.4, where cpuprof.go just appeared with the same result. :-) I think this is expected. Go 1.4 was released in 2014 — several years after the original post about pprof, had been published. In fact, Go 1.4 is the version where the relevant

[go-nuts] Re: question about Profiling Go Programs sample.

2021-09-27 Thread Vladimir Varankin
Hello, I suspect this is due to how the current version of Go runtime's CPU profiler keeps only up to 64 items, when it builds the function's stack frame (refer to https://github.com/golang/go/blob/go1.17/src/runtime/cpuprof.go#L21) With that, the resulting profile misses the relationship

Re: [go-nuts] UML && Golang, part 2 ?

2021-07-05 Thread Vladimir Varankin
For the current system, that concists of <100 µ-services (the whole system is owned by one team), I'm trying to evaluate C4 model https://c4model.com. TBF, this is an ongoing experiment for myself, and I don't try to strictly follow the C4's nomenclature, but I find the idea of zooming-in &

[go-nuts] Re: signal.NotifyContext - Does it expose the signal handled?

2021-05-14 Thread Vladimir Varankin
I don't think the current API provides that functionality. In the original proposal for signal.NotifyContext, there were several discussions, including related to what features the new API should provide. The consensus was that if a user wants to make a decision base on the signal caught, they

[go-nuts] Re: How to implement localhost proxy which injects Proxy-Authorization header to incoming request and sends it to another remote proxy with Go?

2021-03-17 Thread Vladimir Varankin
I think I didn't get what you're building right. Now, it looks like, instead of implementing a custom RR's director, you need to configure its Transport [1], which will be aware of your auth proxy in the middle. Have a look at net/http.Transport.Proxy field [2] for that. [1]:

[go-nuts] Re: How to implement localhost proxy which injects Proxy-Authorization header to incoming request and sends it to another remote proxy with Go?

2021-03-16 Thread Vladimir Varankin
Hey there, Seems the issue hides in the chunk, where you overwrite reverse proxy's "Director" method, which NewSingleHostReverseProxy creates internally. Since your own director doesn't set the client request's Schema and Host, you have to either do that manually or make sure you call the

Re: [go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-05 Thread Vladimir Varankin
golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXNV6bLQQUFmVn14xnxheALTKbv1_oQODovboLEziPKSw%40mail.gmail.com > . > -- Vladimir Varankin vladi...@varank.in -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-02 Thread Vladimir Varankin
Hey, I don't think the statement about "assert going against the best practices in go unit tests" stands against the reality, sorry. One definitely doesn't have to use a separate assertion package to write unit-tests in Go, comparing to some other programming languages. But there is really no

[go-nuts] Re: Better dependency management in go

2020-09-23 Thread Vladimir Varankin
Hey! Several months ago I opened the proposal for extending the systax of go.mod in order to allow to specify/overwrite the source URL for a dependency (https://github.com/golang/go/issues/39536). It feels it could also solve what you described in "Problem 1", although the motivation behind

[go-nuts] Re: What books/tutorail/resources/blog for newcomer to golang?

2020-09-16 Thread Vladimir Varankin
Hey! My peaks, that helped me a lot, back when I started with Go (depending on what's your prefered way to learn and how fast do you have to learn it, some might be less useful than the others. But it's worth to have the options): - Books Go in Action — an extreamly good introduction to the

[go-nuts] Re: Mysterious RSS memory spike

2020-08-24 Thread Vladimir Varankin
Hey, I haven't looked deep but I recall there had been a note about runtime change in Go 1.13's https://golang.org/doc/go1.13#runtime That is > The runtime is now more aggressive at returning memory to the operating system to make it available to co-tenant applications [..] However, on many

[go-nuts] Re: directory name and module name not same, go tool pprof, list function faild

2020-07-31 Thread Vladimir Varankin
Hey, In your example, "~/Documents/tool/tejia_analysis" is your module's source root, right? Could you show where "app_server/util/analysis.go" is on the FS and what is the name of the module? pprof has a coupe flags to manipulate with the path, helping it to search for the source code. I

[go-nuts] Re: arm64 builder on raspberry pi 3B/3B+

2020-02-13 Thread Vladimir Varankin
Note, Ubuntu Server 19.10 (arm64) works out of the box on Raspberry Pi 3 and 4, It might be an easier option. I've written about my experience of running 19.10 on Pi 4 [1]. But I didn't manage to run 18.04 — headless mode just didn't work and I didn't have opportunity to attach a keyboard and

Re: [go-nuts] Compilation fails when adding option "-trimpath", because change a dependency to require gcc

2020-02-10 Thread Vladimir Varankin
I faced the same problem lately. Have open an issue https://github.com/golang/go/issues/37158 On Thursday, February 6, 2020 at 8:53:03 AM UTC+1, Jérôme LAFORGE wrote: > > > I haven't verified this, so this is just a guess, but perhaps without >> -trimpath the go tool is using the prebuilt

[go-nuts] Re: Discrepancy between htop and memstats

2019-05-01 Thread Vladimir Varankin
Hi Michel, Have tried collecting your program's heap profiles [1] (maybe once after each reload cycle)? Comparing pprof results should show you what objects leak memory. [1]: https://blog.golang.org/profiling-go-programs On Tuesday, April 30, 2019 at 3:36:34 PM UTC+2, Michel Levieux wrote: >

[go-nuts] Re: blocking profile

2018-11-16 Thread Vladimir Varankin
I believe, "runtime.chanrecv1" is the receiving part of a channel. From what you've described, it sounds like you have a dead-lock somewhere. In your "out.svg" diagram check what functions are dominating around channel read and check if dead-lock is there. On Thursday, November 15, 2018 at

[go-nuts] Re: Get dependency from enterprise repository

2018-10-09 Thread Vladimir Varankin
Hey there! I don't know much about jfrog, but was curious to delve into the enterprise proxies topic. It seems that you're supposed to use jfrog's own jfrog-cli [1] to work with the artifactory. I believe the CLI simply set a proper value to GOPROXY to URL, that supports gomod proxy protocol

[go-nuts] Re: Performance regression of HTTP requests since Go 1.11

2018-09-06 Thread Vladimir Varankin
I've seen a similar issue on one of your test hosts and it turned out the issue was due to a non-responding NS server in the host's resolv.conf. See https://github.com/golang/go/issues/27525 DNS regression. On Wednesday, September 5, 2018 at 5:07:01 PM UTC+2, mrauh wrote: > > Thanks for your

[go-nuts] Re: Global variable not used, but it works fine

2018-04-23 Thread Vladimir Varankin
I think it's way harder to guaranty that the globals aren't used since even non-exported functions/varibles can be used by the linker. On Saturday, April 21, 2018 at 3:30:22 PM UTC+2, 子風 wrote: > > What did you do? > https://play.golang.org/p/aryK9Btv5kH > > What did you expect to see?

Re: [go-nuts] Debug high GC pause frequency issue

2018-02-07 Thread Vladimir Varankin
> The CPU profiler told me that the program is spending a lot of time doing GC (obviously), and memory profiler is telling me there is a huge amount of memory allocated for json encoding/decoding, which is inevitable for business logic. Even though Go is GC based language, Go prefers object

[go-nuts] Re: Why does go run cmd does not accept a directory as an input

2017-11-07 Thread Vladimir Varankin
Thank you, Dave, for the response. > You’ll have a more enjoyable go experience if you structure your code into packages and use go build or preferably go install. To be fair, I don't think that having the ability to do build + run in one go command goes against the fact that it's worth to

[go-nuts] Why does go run cmd does not accept a directory as an input

2017-11-07 Thread Vladimir Varankin
Currently `go run` accepts a file or a list of ".go" files: ``` % go help run usage: go run [build flags] [-exec xprog] gofiles... [arguments...] ``` For me, it doesn't seem to be obvious, why can't "go run" accept the directory that contains files of the main package as an input? Note, I'm

[go-nuts] Re: Suggestions about reusing function/method information in comments, swagger, logs, events

2017-09-19 Thread Vladimir Varankin
Hi Brunetto, While I don't have "a take and go" solution, I have some thoughts to discuss. What I like about swagger and openapi is the ability to abstract the way you describe your API's, from the particular implementation. This paradigm is (almost) perfectly matches to Go's code generation

[go-nuts] Re: Go at Vimeo in NYC!

2017-09-14 Thread Vladimir Varankin
Do you consider applications from continents other than the US? On Wednesday, September 13, 2017 at 7:45:11 PM UTC+3, gabr...@vimeo.com wrote: > > We have lots of jobs programming in Go at Vimeo's headquarters in NYC! > Please reach out to me at gabr...@vimeo.com if you or > anyone you know

[go-nuts] Re: Go install speedup within docker

2017-06-12 Thread Vladimir Varankin
"-pkgdir" flag of "go build" / "go install" could also be useful, although I haven't tried it. On Monday, June 12, 2017 at 1:06:49 PM UTC+3, Vladimir Varankin wrote: > > I think the difference is that I use my project root as my GOPATH, so pkg > director

[go-nuts] Re: Go install speedup within docker

2017-06-12 Thread Vladimir Varankin
I think the difference is that I use my project root as my GOPATH, so pkg directory ($GOPATH/pkg), which stores the build cache, is mounted inside the container every time I run the build. What if you try ``` docker container run --rm -v $PWD:/usr/src/prj -v $PWD/_build:/usr/pkg ... ``` Doing

[go-nuts] Go install speedup within docker

2017-06-11 Thread Vladimir Varankin
Hey James, Could you show the docker run command, which you invoke to enter a container? I use docker to build my application as well, so I just do `docker container run --rm -ti --volume $PWD:/gocode/src/app --workdir /gocode/src/app go build`. Doing so with container reusage or not, I