Re: [go-nuts] Re: Unicode variable name error

2022-11-06 Thread Konstantin Khomoutov
On Sun, Nov 06, 2022 at 01:45:53PM +0530, Nikhilesh Susarla wrote: >> Per the Go spec[1], an identifier consists of a Unicode letter followed by >> zero or more Unicode letters or digits. The character పే is in the Unicode >> category nonspacing mark rather than the category letter. [...] > So,

Re: [go-nuts] Refactor Asynchronous JS to Go

2022-11-06 Thread Konstantin Khomoutov
On Sun, Nov 06, 2022 at 01:33:59AM +0530, Shubh Karman Singh wrote: > I am refactoring a JS library to Go. I have some questions but I'm not able > to find some concrete answers for this. > 1. What's the idiomatic way to refactor Asynchronous JS APIs to Go? > 2. How to refactor Callbacks from JS

Re: [go-nuts] WebAssembly and Filesystem access

2022-11-05 Thread Konstantin Khomoutov
On Fri, Nov 04, 2022 at 02:08:08PM -0700, 'Kevin Chowski' via golang-nuts wrote: [...] > I am on a project which primarily ships a Go command line interface (CLI), > but we have aspirations of using the wasm compilation mode to also > distribute a simple webapp version of it, while sharing most

Re: [go-nuts] Underscore symbol

2022-11-04 Thread Konstantin Khomoutov
On Fri, Nov 04, 2022 at 04:58:35AM -0700, Canuto wrote: > I'm just starting out with go ... > I have searched for lights on this string but without success. > What does this sign mean " _, err " , what the underscore symbol means here? > If you're starting with Go, please

Re: [go-nuts] fs.Glob, fs.DirWalk, etc. does the pattern support complex regex

2022-11-04 Thread Konstantin Khomoutov
On Thu, Nov 03, 2022 at 01:20:16PM -0700, pat2...@gmail.com wrote: > This has to be a FAQ, but my google foo for searching it is not clear > The docs say: " The syntax of patterns is the same as in path.Match." > > The pattern seems to implement only fairly simple search expressions. > > I'd

Re: [go-nuts] Go Crashes on a long running process (with stack trace)

2022-11-04 Thread Konstantin Khomoutov
On Tue, Nov 01, 2022 at 10:14:28AM -0700, Vineet Jain wrote: > We have a long running process that listens to and processes a large number > of network packets. It died today with the following stack trace. Anyone > seen this before, or have any idea what is causing it? > > Nov 01 12:40:30

Re: [go-nuts] How does the go compiler treat initialized string variables?

2022-11-03 Thread Konstantin Khomoutov
On Tue, Nov 01, 2022 at 11:18:48AM -0700, Frank Jüdes wrote: > I have to write a program that should verify the content of > configuration-servers. It will need a lot of pre-initialized data to verify > the actual content of a server, so it has to initialize many strings. What > i know from

Re: [go-nuts] Understanding some gotchas with linking slices together via indexing

2022-11-03 Thread Konstantin Khomoutov
On Tue, Nov 01, 2022 at 09:38:20PM -0700, Brian, son of Bob wrote: > Can anyone explain these gotchas (demo )? > I've tried reading articles on this [one , [...] > but they don't go into enough detail. Because that's an

Re: [go-nuts] Occasional hard lockup w/ 100% CPU usage in go applications

2022-11-03 Thread Konstantin Khomoutov
On Mon, Oct 31, 2022 at 09:32:21AM -0700, Steven Sokol wrote: > I tried sending SIGABRT, but the process did not respond - continued > running in the runaway state. I can kill it with SIGKILL but that doesn't > generate a core. Can you suggest a specific kill command that will? Thanks! Sending

Re: [go-nuts] about upstream?

2022-11-03 Thread Konstantin Khomoutov
On Wed, Nov 02, 2022 at 02:15:51AM -0700, xie cui wrote: > there are two micro service writen in go, let's call them A and B. A will > call B. In this scene we will call B is the upstream of A. or A is the > upstream of B? which one is correct way? I'm not a native speaker but I would say that

Re: [go-nuts] Re: Atomic pointers to arrays and sequenced-before guarantees for array elements

2022-10-30 Thread Konstantin Khomoutov
On Sun, Oct 30, 2022 at 08:47:41AM -0700, jake...@gmail.com wrote: > I would like to give you a definitive answer, but the same question comes > up in https://groups.google.com/g/golang-nuts/c/Gze1TRtdLdc/ and there is > much disagreement and no clear resolution. (The initial question is not >

Re: [go-nuts] Race detector question

2022-10-30 Thread Konstantin Khomoutov
On Fri, Sep 16, 2022 at 01:26:05PM -0700, 'Keith Randall' via golang-nuts wrote: > Atomic operations can establish happens-before relationships. > > initially, y==0. > > goroutine 1: > x = 99 > atomic.Store(, 1) > > goroutine 2: > if atomic.Load() == 1 { >println(x) > } > > This program,

[go-nuts] Atomic pointers to arrays and sequenced-before guarantees for array elements

2022-10-30 Thread Konstantin Khomoutov
Hi! I would like to receive clarifications, if possible, on Go memory model guarantees about non-atomic load and stores when intermixed with atomic load and stores. I'm reviewing a piece of code which, simplified, works as follows: - There is a single "writer" goroutine which - Allocates

Re: [go-nuts] filepath.walk in Go 1.19

2022-10-30 Thread Konstantin Khomoutov
On Sat, Oct 29, 2022 at 02:54:48PM -0700, Robert Solomon wrote: [...] >>> On ubuntu 22.04, I would like the walk function to NOT follow symlinks to >>> other filesystems. The find command uses the -xdev switch to achieve >>> this. >>> >>> How can I get walk to behave like the -xdev switch to

[go-nuts] cgo: Is it possible to make exported function have __stdcall calling convention?

2022-10-29 Thread Konstantin Khomoutov
Hi! I have a need to create a Windows i386 DLL whose exported functions have __stdcall calling convention - this is the requirement of the piece of software which is to load and call this DLL; we cannot change the caller, and have to adapt to its requirements. The only approach I was able to

Re: [go-nuts] What's the consensus these days on dealing with defer errors?

2022-10-27 Thread Konstantin Khomoutov
On Thu, Oct 27, 2022 at 11:01:01AM -0700, Gergely Brautigam wrote: [...] > > Since Go 1.13 you can also make chains of errors; say, in your second > > example > > you could do > > > > err = fmt.Errorf("doSomething failed with %s while handling %w", > > tmpErr, err) > > > > and then have

Re: [go-nuts] What's the consensus these days on dealing with defer errors?

2022-10-27 Thread Konstantin Khomoutov
On Thu, Oct 27, 2022 at 06:23:31AM -0700, Gergely Brautigam wrote: > I was wondering what's the consensus these days on handling defer errors? > > Is it something like, overwriting the returned value, or using a list of > errors? > > Either: > > func test() (err error) { > defer func() {

Re: [go-nuts] Occasional hard lockup w/ 100% CPU usage in go applications

2022-10-26 Thread Konstantin Khomoutov
On Wed, Oct 26, 2022 at 08:45:00AM -0500, Robert Engels wrote: > Trigger a core dump then use gdb on the core file. Also, the gdb is usually shipped with the `gcore` helper which can attach to the specified PID and dump its core. -- You received this message because you are subscribed to the

Re: [go-nuts] Analyse postgresql error

2022-10-26 Thread Konstantin Khomoutov
On Wed, Oct 26, 2022 at 01:38:51PM +0300, David Harel wrote: [...] > func errorCheckResult(err error) string { > if err == nil { > return "" > } > pqerr := err.(*pq.Error) > switch pqerr.Get('C') { > case "23505": > return "Key violation" > } > return

Re: [go-nuts] Analyse postgresql error

2022-10-25 Thread Konstantin Khomoutov
On Fri, Oct 21, 2022 at 08:17:16AM -0700, David Harel wrote: > Newbie on golang. Using sqlc: https://github.com/kyleconroy/sqlc in the > environment created by Karl Keefer: > https://github.com/karlkeefer/pngr/actions/workflows/build.yml, thanks Karl. > My queries use querier which is auto

Re: [go-nuts] Tracking which connection is used to make an HTTP request

2022-10-25 Thread Konstantin Khomoutov
On Tue, Oct 25, 2022 at 03:43:21PM +0400, Konstantin Khomoutov wrote: >> However, that does not work well for TLS. The reason is that the Go HTTP >> client has special logic in case a custom dialer returns a *tls.Conn. That >> logic will be disabled. > > The Conn f

Re: [go-nuts] Tracking which connection is used to make an HTTP request

2022-10-25 Thread Konstantin Khomoutov
On Wed, Oct 12, 2022 at 09:01:46AM -0700, Christian Worm Mortensen wrote: (I have rehashed the options you've presented, to help commenting on them.) [...] > 2) I can make a my own struct and return from my custom dialer: > > type myConn struct { > net.Conn > dialInfo string > } > >

Re: [go-nuts] Zero-sized data type

2022-10-20 Thread Konstantin Khomoutov
On Thu, Oct 13, 2022 at 10:45:33AM -0700, Richiise Nugraha wrote: > The field can't be reordered. > I want to use zero-sized data type to mark offset and has no effect on > struct size, I can take the address of it and use it like: > ```go > c := ... > cmd := (*[SIZE]byte)(unsafe.Pointer()) >

Re: [go-nuts] go runtime in shared libs functions called in threads

2022-10-20 Thread Konstantin Khomoutov
On Wed, Oct 19, 2022 at 06:28:20AM -0700, Peter Galbavy wrote: > I have built a shared lib in Go to replace an old thing we use to send > email - mainly to modernise things and add TLS and authentication. We run > each call to the entry point in it's own thread in the main program. > > I am

[go-nuts] Write heap dump in a forked process - could that be even possible?

2022-10-10 Thread Konstantin Khomoutov
More than once at my $dayjob we experienced the need to grab the heap dump or a running process implementing some critical functionality. The problem is that saving of the dump file requires freezing of the process, and if its memory consumption is relatively high (in our case it clocked around 50

Re: [go-nuts] goroutine private / local var/const

2022-07-20 Thread Konstantin Khomoutov
On Wed, Jul 20, 2022 at 01:00:59PM +0300, Konstantin Khomoutov wrote: > > for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ > > fmt.Println("f:beg i=",i) // here c or v instead > > // action > > fmt.Println("f:end i=",i) // here c or v i

Re: [go-nuts] goroutine private / local var/const

2022-07-20 Thread Konstantin Khomoutov
On Tue, Jul 19, 2022 at 08:28:02AM -0700, 'andreas graeper' via golang-nuts wrote: > for i=0;i<10;i++ { go func () { /* const c=i OR var v=i */ > fmt.Println("f:beg i=",i) // here c or v instead > // action > fmt.Println("f:end i=",i) // here c or v instead > }} > when this routines get

Re: [go-nuts] how to convert or typecast windows handle/fd to net.conn

2022-07-13 Thread Konstantin Khomoutov
On Tue, Dec 04, 2018 at 12:29:03PM -0800, apmat...@gmail.com wrote: > My problem is following: I need to use windows WSAAccept() instead of > normal accept (net package seems to use AcceptEx). > > I'm I missing somethig > > I do not know a way to extend net-package so only way I know is to

Re: [go-nuts] The program stucked on __vdso_clock_gettime (x86_64)

2022-07-05 Thread Konstantin Khomoutov
On Mon, Jul 04, 2022 at 01:57:06AM -0700, Chenhong Liu wrote: [...] > After profiling the process with perf command, the perf data shows the > program looped to call __vdso_clock_gettime . > > 64.20% controllerd [vdso] [.] __vdso_clock_gettime > 8.82% controllerd controllerd [.]

Re: [go-nuts] ListenAndServeTLS() (pem and key files for private network)

2022-06-30 Thread Konstantin Khomoutov
On Mon, Jun 27, 2022 at 05:35:38PM -0700, Hugh Myrie wrote: > I wish to create a secure private network using a self-signed certificate > with a Go web server: See the following code block: > > // Code > err := http.ListenAndServeTLS(":"+port, "auto.org.pem", > "auto.org-key.pem",

Re: [go-nuts] Go binary, that tries to run shell command in ESXI environment is failing

2022-05-19 Thread Konstantin Khomoutov
On Wed, May 18, 2022 at 09:40:03AM -0700, Ian Lance Taylor wrote: [...] > Thanks for including the strace output. It shows that the clone > system call is failing with ENOSPC. There are several reasons that > clone can fail with ENOSPC. None of them have anything to do with > disk space

Re: [go-nuts] when EOF returned from http client.Post, client can continue to be used ?

2022-04-18 Thread Konstantin Khomoutov
On Sun, Apr 17, 2022 at 06:52:17AM -0700, Toon Knapen wrote: > It is not clear to me from the documentation whether I can continue to use > an http.Client after a POST failed (due to the connection being closed ; > In my case the connection closes probably due to rate-limiting). > > The

Re: [go-nuts] Getting 502 errors in golang with heavy load

2021-08-06 Thread Konstantin Khomoutov
On Fri, Aug 06, 2021 at 08:13:46PM +0300, Konstantin Khomoutov wrote: [...] > * Aerospike does not use HTTP as its client protocol; it implements some >custom protocol over TCP sockets, so that 502 Sorry, fat fingers. I meant to say "... so that those '502 errors' could no

Re: [go-nuts] Getting 502 errors in golang with heavy load

2021-08-06 Thread Konstantin Khomoutov
On Thu, Aug 05, 2021 at 08:07:58PM -0700, Anand vishnu wrote: > my code is running absolutely fine with a smaller load, when load is > increased it is failing. > The changes i made in the newer release tag: > 1. pushing data to aerospike at each and every chunk > when i turn off this line it is

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-06 Thread Konstantin Khomoutov
On Fri, Aug 06, 2021 at 12:42:34AM -0700, Miraddo wrote: Hi! > I can not understand why when we use append, it does not rewrite values in > the same address in the memory that it had before, > > (I'm not sure it "append" problem or the variable | or just my problem for > sure :) ) [...] >

Re: [go-nuts] Re: go install an/import/path@revision and /vendor in Go 1.16

2021-08-06 Thread Konstantin Khomoutov
On Thu, Aug 05, 2021 at 04:39:00PM -0700, Sean Liao wrote: > This is intentional and sort of covered by the statement that no module is > considered the main module (where replace directives and vendor dirs take > effect) I must admit that sentence regarding the main module has caught my

Re: [go-nuts] Re: go install an/import/path@revision and /vendor in Go 1.16

2021-08-06 Thread Konstantin Khomoutov
On Fri, Aug 06, 2021 at 12:35:16AM -0700, Brian Candler wrote: > The key point I just learned from #40276: > "Vendor directories are not included in module zip files." > > I found this surprising because -mod=vendor is now the default (here > ) - therefore,

[go-nuts] go install an/import/path@revision and /vendor in Go 1.16

2021-08-05 Thread Konstantin Khomoutov
Hi! We have recently turned one of our internal Go projects into a Go module. The project was using vendoring and we intend to continue doing so - just rather with the natural support from `go mod` instead of govendor as before. An interesting issue came up when we've decided to try the recently

Re: [go-nuts] Windows Write Call Error when Writing to Network mapped Folder.

2020-09-24 Thread Konstantin Khomoutov
On Tue, Sep 22, 2020 at 10:56:43AM -0700, helhadad wrote: > Hi Folks, > I am trying to create file and write to it on a *network mapped drive*, > which I can access, create, delete and edit files using windows explorer or > CMD (Windows 10/Server 2016). > > You can find all details of the

Re: [go-nuts] Regarding time.NewTicker() and monotonic time

2020-06-17 Thread Konstantin Khomoutov
On Wed, Jun 10, 2020 at 04:03:36PM -0700, Ian Lance Taylor wrote: [...] > In the current implementations of Go, Tickers are not garbage > collected. They run until they are stopped. So if you don't stop a > ticker, it will keep ticking until your program exits. > > (It is possible that future

Re: [go-nuts] json struct tag

2018-01-31 Thread Konstantin Khomoutov
On Wed, Jan 31, 2018 at 09:26:35AM +1030, Dan Kortschak wrote: > > > Does the order in which the options in the tag appear matter (e.g.  > > > `json:"first_name,omitempty"` vs `json:"omitempty,first_name"`) ? > > > > I'd say they should not as their purposes are orthogonal to each > > other. >

Re: [go-nuts] Decoder.DisallowUnknownFields() works when passing *struct but not *map[string]interface{}

2018-01-30 Thread Konstantin Khomoutov
On Sun, Jan 28, 2018 at 10:59:58AM -0800, Trig wrote: > This works as intended when you pass it a pointer to a Struct; however, it > should also work (you would think, since the Unmarshaller can handle both > types) a pointer to a *map[string]interface{}; however, it does not. Are > there any

Re: [go-nuts] json struct tag

2018-01-30 Thread Konstantin Khomoutov
On Sun, Jan 28, 2018 at 09:21:12AM -0800, Trig wrote: > I've searched but can't find any good sources on json struct tag options > and rules... These rules are contained in the pieces of documentation for encoding/json.Marshal and encoding/json.Unmarshal; studying the output of `go doc

[go-nuts] Nested struct types and closing over them in function literals

2017-11-24 Thread Konstantin Khomoutov
We've just have a discussion with a colleague about the case of what exactly variable would a function literal close over, if it calls a method on a field of a struct-typed variable available in the scope of the enclosing function. Here's the code:

Re: [go-nuts] Understanding panic at addr=0x38 when calling a method on a nil interface

2017-11-14 Thread Konstantin Khomoutov
On Mon, Nov 13, 2017 at 03:58:35PM -0800, keith.rand...@gmail.com wrote: [...] What puzzles me, is that the address it panics is not 0x0 (which I would expect from an x86/amd64 H/W platform to stand for nil) but 0x38: [...] >> Konstantin, your description is correct. The code is trying

[go-nuts] Understanding panic at addr=0x38 when calling a method on a nil interface

2017-11-13 Thread Konstantin Khomoutov
While debugging a program which had a panic due to an attempt to call a method on a value of an interface typeš, I came across the behaviour I find strange, and would like to get help understanding what happens. The behaviour is exhibited by this simple program:

Re: [go-nuts] Upcasting/Downcasting in Go

2017-11-09 Thread Konstantin Khomoutov
On Wed, Nov 08, 2017 at 02:48:06PM -0800, Ian Lance Taylor wrote: [...] >> So when should I expect the type casting to work? [...] > When thinking about Go it's best to avoid concepts that do not apply, > like derived class, upcast, and downcast. You can't write >

Re: [go-nuts] XML Parsing Nested Elements

2017-11-07 Thread Konstantin Khomoutov
On Tue, Nov 07, 2017 at 03:35:45AM -0800, lesm...@gmail.com wrote: > I am really struggling to access nested elements of an XML string and > suspect it is down to the namespaces. This string is obtained from a > larger document and is the "innerXML" of some elements. A simplified > version is

Re: [go-nuts] Short Term DSN for database/sql

2017-11-07 Thread Konstantin Khomoutov
On Tue, Nov 07, 2017 at 12:06:27AM -0800, agruet...@gmail.com wrote: > It appears the Generic Interface for SQL (database/sql) does not support > the ability to use short lived DSN's for cases like AWS's IAM > Authentication to RDS instances. It appears that when doing its connection > pooling

Re: [go-nuts] Is there a way or lib to read a binary into a sturct{len int32;data [len]int32}

2017-11-07 Thread Konstantin Khomoutov
On Tue, Oct 31, 2017 at 04:36:20PM +0800, hui zhang wrote: [...] > > > Is there a way or lib to read a binary into a this structure in one line > > > code? > > > > > > how about more complicate struct ? > > > type complicatestrt struct { > > > len int32 > > > strData []variastrt > > >

Re: [go-nuts] sync.Map performance problem

2017-10-25 Thread Konstantin Khomoutov
On Fri, Oct 20, 2017 at 11:50:42PM -0700, barce show wrote: > I use sync.Map in my program to support access concurrently, but witin two > hours with less than 50 clients, my program run out all of my cpu, so I go > back to read the pkg document, and I find this sentence > > "For use cases

Re: [go-nuts] Re: XML unmarshaller doesn't handle whitespace

2017-10-05 Thread Konstantin Khomoutov
On Thu, Oct 05, 2017 at 12:48:53AM -0700, Per Persson wrote: > > Probably it's best to ask here before I try to contact the Go developers. > > > > I had a file with space padded numbers (NumberOfPoints=" 266703") and > > the XML unmarshaller couldn't handle the spaces. > > > > Booleans are

Re: [go-nuts] XML unmarshaller doesn't handle whitespace

2017-10-05 Thread Konstantin Khomoutov
On Mon, Oct 02, 2017 at 03:10:19AM -0700, Per Persson wrote: > Probably it's best to ask here before I try to contact the Go developers. > > I had a file with space padded numbers (NumberOfPoints=" 266703") and the > XML unmarshaller couldn't handle the spaces. > > Booleans are trimmed >

Re: [go-nuts] `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-18 Thread Konstantin Khomoutov
On Sat, Sep 16, 2017 at 04:51:00AM +0800, Sen Han wrote: > Thanks for your information. I want to use `ltrace` to find out if the > golang binary is using > the __vdso_clock_gettime_sym with CLOCK_MONOTONIC option for measuring time > interval. > > But it finally turns out currently the `ltrace`

Re: [go-nuts] `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-15 Thread Konstantin Khomoutov
On Fri, Sep 15, 2017 at 04:09:24AM -0700, nehs...@gmail.com wrote: > Hi, I just found `ltrace` would yield "Couldn't find .dynsym or .dynstr in > "/proc/*/exe" with executable binary generated by "go build *.go". > > Is there any options in `go build` could solve this problem? > > Thanks a

Re: [go-nuts] Doing "C-like" things in Go

2017-09-12 Thread Konstantin Khomoutov
On Mon, Sep 11, 2017 at 09:56:59AM -0700, CampNowhere wrote: > I am a C developer and am trying to pick up Go. > > My question is this. C doesn't "care" about truthfulness, it just cares > about zero and non-zero when evaluating a logical AND operator. So > something like the following in C is

Re: [go-nuts] A question about evaluation of channel’s send statement

2017-09-12 Thread Konstantin Khomoutov
On Wed, Sep 06, 2017 at 04:26:09AM -0700, T L wrote: > > > It is just weird that the evaluation timing of *p is different to other > > expressions, such as, *p+0, *p*1, func()int{return *p}m etc. > > > > The value depends on a data race so it's entirely undefined in all cases. > > That the

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-11 Thread Konstantin Khomoutov
On Mon, Sep 11, 2017 at 08:49:30PM +1200, Tim Uckun wrote: > | However, what's great for avoiding straightforward failures becomes a > | nightmare when your goal is to guarantee that no undefined behaviour > | happens > > It seems to me that if this is your goal other languages are more

Re: [go-nuts] Re: error handling needs syntactical sugar

2017-09-11 Thread Konstantin Khomoutov
On Wed, Sep 06, 2017 at 11:00:08PM -0700, Tim Uckun wrote: > Totally not a go programmer but here are my worthless two cents. > > I don't see anything wrong with the try catch paradigm, you can choose your > granularity. If you want to check every call then you can, if you want to > let a few

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Konstantin Khomoutov
[...] > > AFAIK, all operations on a channel happen in-order and are fully > > serialized. That is, close() will wait until the currently active > > operation > > is active, if any. > > > > In other words, close() on a channel is not like closing an OS file > > descriptor -- even though the

Re: [go-nuts] closing a channel to interrupt a send: racy, but incorrect?

2017-08-31 Thread Konstantin Khomoutov
On Thu, Aug 31, 2017 at 05:08:23AM -0700, Jason E. Aten wrote: > A question for those familiar with the runtime internals of channel close > and channel receive: [...] > Will closing a channel in the middle of a send introduce the possibility of > data corruption? The language spec guarantees a

Re: [go-nuts] Building gopath packages

2017-08-31 Thread Konstantin Khomoutov
> > See github.com/rjeczalik/gobin for updating, but a simple > > "go install $GOPATH/src/..." may be enough. > > The URL appears to 404. There are multiple projects called "gobin" on > Github but neither appear to be concerned with the task we're > discussing, unfortunately. Citing the answer

Re: [go-nuts] Building gopath packages

2017-08-31 Thread Konstantin Khomoutov
On Wed, Aug 30, 2017 at 10:35:46PM -0700, Tamás Gulácsi wrote: > See github.com/rjeczalik/gobin for updating, but a simple > "go install $GOPATH/src/..." may be enough. The URL appears to 404. There are multiple projects called "gobin" on Github but neither appear to be concerned with the task

Re: [go-nuts] english language help

2017-08-30 Thread Konstantin Khomoutov
On Wed, Aug 30, 2017 at 07:17:26PM +0600, Oleg Puchinin wrote: > Hello ! > Anybody speak russian ? > I work on "Jay" - indexer for Go language (for LiteIDE). Can anybody speak > my this theme in russian language ? > > Last link: > svn checkout --username=olegpuchinin svn+ssh:// >

Re: [go-nuts] Re: Convert grid of colors to SVG

2017-08-29 Thread Konstantin Khomoutov
On Mon, Aug 28, 2017 at 06:35:25AM -0700, ajstarks wrote: > it would be helpful to better understand what you want to do, but: > > https://speakerdeck.com/ajstarks/svgo-code-plus-picture-examples > > includes the code below (with many other examples would should be > illustrate the

Re: [go-nuts] ANN: xcryptossh: an ssh library with per channel timeouts and context based cancellation

2017-08-29 Thread Konstantin Khomoutov
On Sat, Aug 26, 2017 at 04:47:04PM -0700, Jason E. Aten wrote: > https://github.com/glycerine/xcryptossh > > This is an evolution of golang.org/x/crypto/ssh to fix memory leaks, > provide for graceful shutdown, and implement idle timeouts for each > multiplexed channel. It is not API backwards

Re: [go-nuts] Using pprof on publicly accessible servers

2017-08-28 Thread Konstantin Khomoutov
On Mon, Aug 28, 2017 at 08:25:05AM -0700, st ov wrote: > It's recommended to add pprof to servers > > import _ "net/http/pprof" > > Is this true even for publicly exposed servers? How do you limit access? Either through your custom ServeMux or by reverse-proxying to your Go server via

Re: [go-nuts] Custom ServeMux and pprof

2017-08-28 Thread Konstantin Khomoutov
On Mon, Aug 28, 2017 at 08:31:11AM -0700, st ov wrote: > How do you add pprof to a custom ServeMux? > > https://golang.org/pkg/net/http/#ServeMux > > Its my understanding that the following import only adds handlers to the > default mux. > > import _ "net/http/pprof"

Re: [go-nuts] Convert grid of colors to SVG

2017-08-28 Thread Konstantin Khomoutov
On Fri, Aug 25, 2017 at 10:18:17AM -0700, steve_bagw...@sil.org wrote: > > There's svgo: https://github.com/ajstarks/svgo [...] > Thanks Andrey, > SVGO didn't seem to include that particular functionality. Maybe I just > didn't look carefully enough? So, this begs the question: why producing

Re: [go-nuts] Help! Same code, different results

2017-08-25 Thread Konstantin Khomoutov
On Fri, Aug 25, 2017 at 08:39:29AM -0700, Tong Sun wrote: > I'm experiencing a *very very* strange problem now -- the same Go code is > producing different results *for me*. [...] > Can someone verify for me what you get please? > > go get github.com/go-dedup/fsimilar > > then > > cd

Re: [go-nuts] Re: Go 1.9 is released

2017-08-25 Thread Konstantin Khomoutov
On Fri, Aug 25, 2017 at 02:05:52AM -0700, Igor Maznitsa wrote: > and why the SDK is not presented in the list > https://storage.googleapis.com/golang/ ? > also under Ubuntu 16.04 LTS I have some error for any attempt to start Go > 1.9 from downloaded SDK : > /lib/ld-linux-aarch64.so.1: No

[go-nuts] Understanding "scheduler latency profile" charts

2017-08-24 Thread Konstantin Khomoutov
Hi! We're trying to investigate a case of pathological behaviour of one of one HTTP services (built with Go 1.8) under heavy load. The current hypothesis is that under the load being considered, the scheduler (or the set of available Ps) have hard time serving that load. We came to this

Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Konstantin Khomoutov
On Tue, Aug 22, 2017 at 07:38:03AM -0700, Tong Sun wrote: > How to initialize a go struct like the following? > > type Server struct { > Namestring > ID int32 > Enabled bool > } This type definition looks pretty much OK. > s := struct { > Servers []Server{ > { >

Re: [go-nuts] Testing that an implementation satisfies an interface in the standard library

2017-08-22 Thread Konstantin Khomoutov
On Mon, Aug 21, 2017 at 10:05:12PM +0200, 'Axel Wagner' via golang-nuts wrote: > > Satisfying a standard interface like io.Reader or io.Writer correctly is > > not just a matter matching the function signatures, but rather adhering to > > behaviour that is documented in comments > >

Re: [go-nuts] Why constant is not addressable in golang?

2017-08-21 Thread Konstantin Khomoutov
On Mon, Aug 21, 2017 at 12:56:19PM +, Jan Mercl wrote: >> That is >> >> const onethird = 1 / 3 >> >> has greater precision than >> >> onethird := float64(1) / 3 > > Zero does not seem to have greater precision than 0. when > approximating the real number 1/3. IMHO, the less

Re: [go-nuts] Why constant is not addressable in golang?

2017-08-21 Thread Konstantin Khomoutov
On Sun, Aug 20, 2017 at 10:23:27PM -0700, chou wrote: > I guess that const will be substitute literally at compile time > for performance improvements. So there is not such variable in > run time. > > Is it right? One of the reasons for this is that constants in Go have properties which set

Re: [go-nuts] WaitGroup should be introduced before "Exercise: Web Crawler" in "A Tour of GO"

2017-08-21 Thread Konstantin Khomoutov
On Sun, Aug 20, 2017 at 08:20:08AM -0700, 823545...@qq.com wrote: > I'm a freshman. I went through the Tour of GO smoothly today, until I > encountered "Exercise: Web Crawler". The exercise is at here > https://tour.golang.org/concurrency/10 . > This exercise requires me to implement a

Re: [go-nuts] Segmentation fault when linking with Go library from a C++ program

2017-08-18 Thread Konstantin Khomoutov
On Fri, Aug 18, 2017 at 04:21:27AM -0700, ine...@gmail.com wrote: > I have a C++ application from which I need to call Go functions. I noticed > that the application crashes > on exit from the `main` function (with only a "Segmentation fault" message, > no core dump Not to answer your question,

Re: [go-nuts] Domain-driven design and go

2017-08-18 Thread Konstantin Khomoutov
On Fri, Aug 18, 2017 at 03:29:01AM -0700, Hugo Torres wrote: > Recently I've been reading "Domain Driven Design" and I think it has some > useful stuff about organizing Go programs. > > I wrote some of my thoughts up on my blog here > . > > Would love to

Re: [go-nuts] How do you debug Go itself on VM env or Docker container?

2017-08-18 Thread Konstantin Khomoutov
On Fri, Aug 18, 2017 at 12:26:02AM -0700, 高橋誠二 wrote: > I'm trying to debug and run `./all.bash` with VM or docker, but they don't > work for several reasons. > > On VM, I added box of CentOS and Ubuntu, though, they cancels ./all.bash at > `hardlink` testing. The "VM" is too vague a term

Re: [go-nuts] The memory release about Turning C arrays into Go slices

2017-08-18 Thread Konstantin Khomoutov
On Fri, Aug 18, 2017 at 10:39:29AM +0300, Konstantin Khomoutov wrote: [...] > There can't be easy answer to a question like this in C. > Consider: > > // This function clearly transfers the ownership of the memory > // it returns to the caller. > int* allocate(int n) &g

Re: [go-nuts] The memory release about Turning C arrays into Go slices

2017-08-18 Thread Konstantin Khomoutov
On Thu, Aug 17, 2017 at 06:50:42PM -0700, jianzhang...@gmail.com wrote: > > > As the instruction > > > of https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices > > > shows, the GC of Go will not release it. > > > An example as the following, but I have a question about when and

Re: [go-nuts] Calling Julia from Go

2017-08-18 Thread Konstantin Khomoutov
On Wed, Aug 16, 2017 at 11:57:51PM -0700, mrech...@gmail.com wrote: > I would like to implement a valuation server. For the whole server > infrastructure I would like to use Go, because it feels more natural than > any other language for it. For the implementation of the valuations I would >

Re: [go-nuts] studying golang code

2017-08-16 Thread Konstantin Khomoutov
On Tue, Aug 15, 2017 at 02:42:45PM -0700, Keith Brown wrote: [...] > Now, as I learn golang, are there any worth while projects I can use as > reference for writing high quality go code? I am not necessary looking for > code standards but more of code setup and quality so I can practice those

Re: [go-nuts] Receiving Post Using Go

2017-08-14 Thread Konstantin Khomoutov
On Mon, Aug 14, 2017 at 05:06:08AM -0700, Kennedy Kanyi wrote: > I would want to inquire how I can receive POST data from a URL using Golang. > > A case study would be where a system sends a username and password via POST > and my Go receiving file reads the post and the values. In addition to

Re: [go-nuts] ungetc behavior in go

2017-08-14 Thread Konstantin Khomoutov
On Mon, Aug 14, 2017 at 05:43:04AM -0700, Doğan Kurt wrote: > > Consider combining using the bufio package and scanning form a buffered > > reader using fmt.Fscanf(). > > Great worked like a charm. I just thought i couldn't pass *bufio.Reader to > Fscanf which takes io.Reader. Oh, then

Re: [go-nuts] ungetc behavior in go

2017-08-14 Thread Konstantin Khomoutov
On Mon, Aug 14, 2017 at 05:09:00AM -0700, Doğan Kurt wrote: > I want to do something analogous to this C code. > > c = getchar() > > if (isdigit(c)) { > ungetc(c, stdin); > scanf("%d", ); > } > > In fmt package, fmt.Scanf("%d", ) exists but ungetc doesn't exist. For > bufio package, Peek

Re: [go-nuts] how can I decrypt "ENCRYPTED PRIVATE KEY" using golang

2017-08-11 Thread Konstantin Khomoutov
On Fri, Aug 11, 2017 at 12:30:56AM -0700, terry.an...@gmail.com wrote: > My private key is generated by "openssl req -new -x509 -keyout a.key -out > a.crt -days 3650" with password. > > And I tried to decrypted it by x509.DecryptPEMBlock(keyBlock, password), > but failure. error message:

Re: [go-nuts] Check for minimum Go version

2017-08-10 Thread Konstantin Khomoutov
On Wed, Aug 09, 2017 at 03:11:48PM +0200, Michael Banzon wrote: > Is there a way to have a (bash) script check if the version of the Go > compiler installed is a specific minimum version? In the light of [1], I think you could combine checking of the presense of the `go` tool itself with build

Re: [go-nuts] Can warnings of race detector be ignored and toleranted?

2017-08-09 Thread Konstantin Khomoutov
On Tue, Aug 08, 2017 at 07:52:19PM -0700, Cholerae Hu wrote: > Some of my colleagues think that, in some cases, such as approximately > counting the sum total of requests, we don't need to know the accurate > value, so we can let several goroutines to access one variable without lock > or

Re: [go-nuts] Re: Go channels overused and hyped?

2017-08-08 Thread Konstantin Khomoutov
On Tue, Aug 08, 2017 at 03:39:42AM -0700, snmed wrote: > > There are trade-offs. > > > > Channels are easy to use for simple things, but complicated for complected > > things. > > > > Locking data-structures can easily introduce data-races (see The Little > > Book of Semaphores

Re: [go-nuts] [CGO] how to pass a 2d slice to C?

2017-08-08 Thread Konstantin Khomoutov
On Mon, Aug 07, 2017 at 08:20:01PM -0700, jianzhang...@gmail.com wrote: [...] > > > > > golevelmatrix := [][]int{{1}, {3, 3}, {3, 3, 2}} > > > > >levelmatrix := make([][]C.int, len(golevelmatrix)) > > > > >for i, _ := range golevelmatrix { > > > > >levelmatrix[i] =

Re: [go-nuts] [CGO] how to pass a 2d slice to C?

2017-08-07 Thread Konstantin Khomoutov
On Mon, Aug 07, 2017 at 06:25:48AM -0700, jianzhang...@gmail.com wrote: > Thank you very much for your patience and help. I got it and will try it > later. :) Glad to help! > > > golevelmatrix := [][]int{{1}, {3, 3}, {3, 3, 2}} > > >levelmatrix := make([][]C.int, len(golevelmatrix))

Re: [go-nuts] [CGO] how to pass a 2d slice to C?

2017-08-07 Thread Konstantin Khomoutov
On Sun, Aug 06, 2017 at 07:08:03PM -0700, jianzhang...@gmail.com wrote: > Thanks your reply, I also used this way, but it still not work. code as the > following. > > gonameunits := []string{"gpu0", "gpu1", "gpu2", "gpu3"} >nameunits := make([]*C.char, len(gonameunits)) >for i, _ :=

Re: [go-nuts] Goroutines chan to get data at specific time

2017-08-07 Thread Konstantin Khomoutov
On Sun, Aug 06, 2017 at 12:53:08AM -0700, desaiabhi...@gmail.com wrote: > Can you please help with below code to get output at specific cutoff time > and exit [...] > c1 := make(chan string) > > go func() { //Sending data after certain time > > c1 <- "result 1" > >

Re: [go-nuts] all goroutines are asleep - deadlock!

2017-08-07 Thread Konstantin Khomoutov
On Fri, Aug 04, 2017 at 08:11:45AM -0700, prankpla...@gmail.com wrote: [...] > func fact_worker(fact_resp_chan chan string, x int) { > defer wg.Done() > response := factorial(x) > fact_resp_chan <- fmt.Sprintf("Factorial of %d is : %d", x, response) > } [...] Please also consider naming your

Re: [go-nuts] Size of struct{}?

2017-08-04 Thread Konstantin Khomoutov
On Fri, Aug 04, 2017 at 02:25:01AM -0700, 樊冰心 wrote: [...] > type T struct { > i int > x struct{} > } > > func main() { > var t T > fmt.Println(unsafe.Sizeof(t)) > } > > Since size of struct{} is 0, why the result is 16? Consider also reading https://dave.cheney.net/2014/03/25/the-empty-struct

Re: [go-nuts] Calling a C function from Go code in cgo must new a thread

2017-08-04 Thread Konstantin Khomoutov
On Fri, Aug 04, 2017 at 03:45:49AM -0700, bysui hou wrote: > I'm going to use CGO to call c++ in my project and do some performance > tests. So I do research on cgo, and find that calling a C function from Go > code won't block other goroutines from running. I view the cgocall code >

Re: [go-nuts] [CGO] how to pass a 2d slice to C?

2017-08-04 Thread Konstantin Khomoutov
On Fri, Aug 04, 2017 at 02:09:14AM -0700, jianzhang...@gmail.com wrote: > Hey Guys, > > I'm in trouble in the same issue. My code as the following: > > test.go > ```go > name := []string{"gpu0", "gpu1", "gpu2", "gpu3"} > matrix := [3][3]int{{1, 0, 0}, {3, 3, 0}, {3, 3, 2}} > >

[go-nuts] accept(2), runtime.LockOSThread and goroutine scheduling

2017-08-04 Thread Konstantin Khomoutov
We're experiencing a problem with our program which serves HTTP requests. Its clients have TCP connection timeouts set to 1 second, and under certain pattern of heavy load the server fails to perform some net.netFD.Accept() calls in time so a fraction of clients gets I/O timeouts when attempting

  1   2   3   >