[go-nuts] Re: Wrong output for (*http.Request).Write with custom io.ReadCloser body

2021-09-17 Thread Brian Candler
All chunks must be prefixed by a chunk length - even if that length is zero. On Friday, 17 September 2021 at 16:53:07 UTC+1 dmo...@synack.com wrote: > Oh, thanks for clarifying that. But still, even if transfer encoding will > be chunked, I don't see why it would make up a body of "0\r\n\r\n"

Re: [go-nuts] smtp.SendMail not using the from argument

2021-09-10 Thread Brian Candler
If you are using Google's SMTP servers, then it validates the From: header and restricts it to those which you have registered against that account. You can register additional addresses (including non-Google ones): Settings > See all settings > Accounts and Import > Send Mail As (Use Gmail

Re: [go-nuts] Re: Debugging "fatal: morestack on gsignal"

2021-09-09 Thread Brian Candler
Just a random thought, but have you tried 1.16 with GODEBUG=asyncpreemptoff=1 ? The preemptive scheduling stuff was introduced in 1.14 I believe. On Thursday, 9 September 2021 at 16:28:38 UTC+1 varun...@gmail.com wrote: > @Kurtis, Thanks for the reply. > > Yes. We upgraded to 1.16.5 due to

Re: [go-nuts] Does the module name have to include the repo name when you publish a Go module?

2021-09-08 Thread Brian Candler
There is also the "replace" directive: mkdir mod1 mod2 cd mod1 go mod init key-value-mod === code.go === package kv import ( "fmt" ) func DoIt() { fmt.Println("Hello") } cd ../mod2 go mod init bar go mod edit -replace=key-value-mod=../mod1 === prog.go === package main import (

[go-nuts] Re: Questions raised by "Understanding Allocations: the Stack and the Heap - GopherCon SG 2019"

2021-09-07 Thread Brian Candler
> By the way, if someone can explain me what is going on with "println", I would be gratefully. This isn't important to me, since "fmt" give me what I need, but I just curious what Walker used it. https://golang.org/ref/spec#Bootstrapping https://golang.org/ref/spec#Predeclared_identifiers --

Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread Brian Candler
Ah I see. In particular, if you have a slice whose len and cap are both 1000, the new cap is 2048; but if you have a slice whose len and cap are both 1100, then the new cap is 1408. I don't see that as a problem in any shape or form. All that's required is: (1) New cap is at least as large as

Re: [go-nuts] Re: slices grow at 25% after 1024 but why 1024?

2021-09-05 Thread Brian Candler
I'm not sure you're clear about what "monotonically increasing" means. Are you saying that there are some cases where append() results in the allocated size of a slice *shrinking*? If so, please demonstrate. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-09-04 Thread Brian Candler
examples in Go's stdlib, maybe this can > be done? > > Best > Kamil > > pt., 3 wrz 2021 o 21:42 Brian Candler napisał(a): > >> I believe (?m) applies to the current group only; if you want to "unset" >> it then start a separate group. >> https

[go-nuts] Re: WASM Performance

2021-09-03 Thread Brian Candler
Could you explain a bit more about what you're comparing? - Is the wasm version running in a browser? If so, which one? Or have you got a way to run wasm directly on the host (in which case, what is it)? - How is the linux/amd64 version running, if it's not talking to a DOM-type environment?

Re: [go-nuts] Managing perpetually running goroutines

2021-08-30 Thread Brian Candler
estion, can come back once I've explored some > options. > > On Mon, 30 Aug 2021, 12:20 Brian Candler, wrote: > >> Also: you can use the same context for all the workers (if that's >> appropriate); or if you want each worker to have a different context, you >> can make t

Re: [go-nuts] Managing perpetually running goroutines

2021-08-30 Thread Brian Candler
Also: you can use the same context for all the workers (if that's appropriate); or if you want each worker to have a different context, you can make those contexts children of the same top-level context. In that case, you only need to cancel one context and all the workers will stop, without

[go-nuts] Re: Installation of go1.17.linux-amd64.tar.gz onto Ubuntu Linux Desktop 20.04.3 LTS failed

2021-08-29 Thread Brian Candler
On Sunday, 29 August 2021 at 06:06:00 UTC+1 fajars...@cloudgdrive.com wrote: > QUESTION: > > why the active Go is not what i expected ? => go1.17 > > Type "which go". It will show you where the "go" binary is that's being picked up. It appears you have go 1.16 installed elsewhere, and is being

[go-nuts] Re: Questions about documentation of Go standard library

2021-08-29 Thread Brian Candler
On Friday, 27 August 2021 at 06:14:45 UTC+1 Volker Dobler wrote: > For most inputs the value is strictly determined by what the functions does > (number of bits needed to represent), so Len(9) == 3. > To be pedantic, Len(9) == 4 :-) -- You received this message because you are subscribed to

Re: [go-nuts] What happens if Golang calls a shared .so library via cgo but this library is built from Golang?

2021-08-20 Thread Brian Candler
Perhaps what you're trying to achieve can be done using Go Plugins instead, although beware of significant restrictions: https://medium.com/learning-the-go-programming-language/writing-modular-go-programs-with-plugins-ec46381ee1a9

[go-nuts] Re: database/sql doubt

2021-08-13 Thread Brian Candler
This is a duplicate of https://groups.google.com/g/golang-nuts/c/Fma0vMPIC8I On Thursday, 12 August 2021 at 21:20:34 UTC+1 dop...@gmail.com wrote: > Hello guys! > > Why *sql.Row don´t implements the Columns() method ? > > Thanks! > -- You received this message because you are subscribed to the

Re: [go-nuts] The behavior of the function variable which points to the struct method

2021-08-11 Thread Brian Candler
On Wednesday, 11 August 2021 at 09:23:44 UTC+1 Brian Candler wrote: > v := Zoo{} > Display1(v) # v is copied > vp := > Display2(vp) # vp is copied > > Correction: vp := or vp := {...} > These are identical, consistent behaviours. > > So now onto

Re: [go-nuts] The behavior of the function variable which points to the struct method

2021-08-11 Thread Brian Candler
On Tuesday, 10 August 2021 at 22:50:00 UTC+1 lege...@gmail.com wrote: > And I'm still a little confused here, you know when we use the struct > method directly, it is only when the function is called that the type of > receiver determines whether the passed struct is a pointer or a copied >

[go-nuts] Re: What does io.Closer.Close do?

2021-08-10 Thread Brian Candler
It's for file-like objects that should be closed when they're no longer being used, in order to reclaim resources promptly. The details depend on the underlying type, but see for example os.File.Close : "Close closes the File, rendering it unusable for I/O.

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

2021-08-08 Thread Brian Candler
On Friday, 6 August 2021 at 18:00:35 UTC+1 Konstantin Khomoutov wrote: > Have you read and understood [1] and [2]? > ... > 1. https://blog.golang.org/slices-intro > 2. https://blog.golang.org/slices > > Also possibly of interest (although it doesn't mention rotation):

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

2021-08-06 Thread Brian Candler
On Friday, 6 August 2021 at 11:46:24 UTC+1 Konstantin Khomoutov wrote: > 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." > > > &

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

2021-08-06 Thread Brian Candler
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, I expected the vendor directory, if present in the source, always to be

[go-nuts] Re: How to implement authorization_code grant flow in golang to login to Azure AD

2021-08-01 Thread Brian Candler
Is this a web app you're writing, or a CLI app? If it's a CLI app, then you need to trigger a request to open a browser. There's a go library to do this: github.com/pkg/browser. Look at how kubelogin does it: https://github.com/int128/kubelogin If it's a web app, then the user is already

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-29 Thread Brian Candler
You might also want to look at podman, which runs containers directly as processes under your own userid with no docker daemon - and buildah, the corresponding tool for creating container images. I use them quite a lot for building and running container images before deploying them to

[go-nuts] Re: Small number change will affect benchmark results

2021-07-28 Thread Brian Candler
number change will affect benchmark results") is normal and unremarkable. On Wednesday, 28 July 2021 at 18:30:09 UTC+1 tapi...@gmail.com wrote: > I think this one is different from previous. I don't criticize Go, I just > seek reasons. > > On Wednesday, July 28, 2021 at 11:44:13 AM U

[go-nuts] Re: Small number change will affect benchmark results

2021-07-28 Thread Brian Candler
I think you have created rather a lot of threads recently on exactly the same topic: https://groups.google.com/g/golang-nuts/search?q=tapi%20benchmark I'm not convinced that another one is needed. There have been good answers in the previous threads. Go has a fairly complex runtime (as you'll

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Brian Candler
As a complete guess: perhaps the .NET sorter is replacing underscore with space before sorting? You'll need to do some further experimentation to prove or disprove this theory. But if it's true, you can change your Less function in a corresponding way. Of course, that still begs the question

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Brian Candler
ermine the lowest level for > indentation - so a depth first search - causing the entire tree to be > traversed and retained before it can output anything. > > On Jul 21, 2021, at 9:40 AM, Brian Candler wrote: > > But AFAICT, it should generate output as it runs. The fact that

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Brian Candler
of litter > that destroyed my machine memory. Everything's working fine now. > Sorry for the unnecessary noise guys. *retreating in shame* > > Have a great day! > > Le mer. 21 juil. 2021 à 16:40, Brian Candler a écrit : > >> But AFAICT, it should generate output as it runs. The f

Re: [go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Brian Candler
But AFAICT, it should generate output as it runs. The fact that it doesn't generate any output at all is suspicious. On Wednesday, 21 July 2021 at 13:50:37 UTC+1 ren...@ix.netcom.com wrote: > Since litter checks for circular references it needs to keep a ref to > every object it sees. > >

[go-nuts] Re: Out of memory using golang.org/x/tools/go/packages

2021-07-21 Thread Brian Candler
The problem appears to be with litter, not with x/tools/go/packages On my machine, this hangs after "Stage B": https://play.golang.com/p/N2MTQszvnRN On Wednesday, 21 July 2021 at 11:41:39 UTC+1 mlevi...@gmail.com wrote: > Hi all, > > I'm having a very hard time with

Re: [go-nuts] Re: How can I break out of a goroutine if a condition is met?

2021-07-21 Thread Brian Candler
defer wg.Done() >> for b := range c { >> fmt.Printf("Hello %t\n", b) >> } >> }() >> c <- true >> c <- true >> close(c) >> wg.Wait() >> } >> >> Dave Chenney has grea

[go-nuts] Re: How can I break out of a goroutine if a condition is met?

2021-07-20 Thread Brian Candler
Which goroutine panics: the one which got a successful login, or the other ones? If the goroutine which sees a successful login panics, then that's a problem with that particular goroutine, and you'll need to debug it in the normal way. Reading the panic message carefully would be a good

[go-nuts] Re: how to create array of structures instances for the nested structures

2021-07-14 Thread Brian Candler
https://play.golang.org/p/YtxPYZ4H-Sy In practice, you'll usually find you want to create a slice, not an array. Arrays have a fixed size. On Wednesday, 14 July 2021 at 16:32:13 UTC+1 trivedi...@gmail.com wrote: > Hi all, it would be helpful for me if a small doubt of mine is resolved. > > I

[go-nuts] Re: heap space not released by the end of program ?

2021-07-13 Thread Brian Candler
On Tuesday, 13 July 2021 at 03:52:24 UTC+1 bai...@gmail.com wrote: > Hi, I wrote a test program, which tests when GC starts to return heap > space to OS. > Here's the code: https://paste.ubuntu.com/p/jxHqDnsM2T/ > > But I've waited for a long time and haven't seen the RSS memory reduced. I >

Re: [go-nuts] Documentation on golang packages and import syntax

2021-07-11 Thread Brian Candler
On Sunday, 11 July 2021 at 10:21:53 UTC+1 Shulhan wrote: > Assuming that you are not enabling Go module, anything under > "$HOME/go/src/" directory will be considered as importable. > But you really, really SHOULD be using module mode. You soon may not have any choice:

Re: [go-nuts] Re: How to implement this in golang?

2021-07-08 Thread Brian Candler
standing >>>> of >>>> where to start and how to implement your program. Otherwise I think this >>>> will all only get you confused. >>>> And understanding at least the important basics of Go will help you >>>> explain your pain

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Brian Candler
hem! ahah > About the errors, I tried to convert ( cmd.Stdout ) io.Write to bytes/ > strings, but.. I have then entered into a loop of errors... > > > > Il giorno martedì 6 luglio 2021 alle 21:32:10 UTC+2 Brian Candler ha > scritto: > >> You haven't shown which lines 75,

Re: [go-nuts] Re: How to implement this in golang?

2021-07-06 Thread Brian Candler
You haven't shown which lines 75, 76 and 83 correspond to. It's easier if you put the whole code on play.golang.org, and we'll be able to point to the error. But I'm guessing it's this: data := cmd.Stdout ... n := int(math.Min(float64(rand.Intn(len(data))), float64(len(data << line

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread Brian Candler
@gmail.com wrote: > Sorry, I post the wrong anchor. It is line 1068: > https://github.com/golang/go/blob/d19a53338fa6272b4fe9c39d66812a79e1464cd2/src/runtime/stack.go#L1068 > > On Wednesday, June 30, 2021 at 5:08:30 AM UTC-4 Brian Candler wrote: > >> On Wednesday, 30 June 2021 at 0

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread Brian Candler
On Wednesday, 30 June 2021 at 08:25:59 UTC+1 tapi...@gmail.com wrote: > > It looks this line > https://github.com/golang/go/blob/master/src/runtime/stack.go#L1078 never > gets executed. > > Can you quote the line you're referring to? Line numbers can shift up and down as commits are made to

[go-nuts] Re: How to implement this in golang?

2021-06-29 Thread Brian Candler
What sort of socket - TCP or UDP? TCP is an infinite stream, and there is no reliable way to divide it into "chunks" (except possibly using the URG pointer, which is very rarely used). There is no guarantee that waiting 1.6 seconds between sends will actually send in separate segments being

Re: [go-nuts] Re: Upgrade to Go1.16 from Go1.14 broke my query

2021-06-28 Thread Brian Candler
I suggest the issue tracker for the firebirdsql library is the right place. On Monday, 28 June 2021 at 16:17:22 UTC+1 hugh@gmail.com wrote: > Stripped down file is attached. > > Go version 1.14.15 > DB was created in Firebird 3.0. > > -- You received this message because you are

Re: [go-nuts] Re: Upgrade to Go1.16 from Go1.14 broke my query

2021-06-28 Thread Brian Candler
l { > respondWithError(w, http.StatusBadRequest, err.Error()) > logError(err.Error()) > return > } > respondWithJSON(w, http.StatusOK, tests) > > } > > *The call (from the browser):* > > 192.168.0.13:8080/test > > *The Error*: > > {"error":"

Re: [go-nuts] Re: Upgrade to Go1.16 from Go1.14 broke my query

2021-06-28 Thread Brian Candler
;> deleted the library and reinstalled it . I suppose doing a "go get" without >> specifying a version would retrieve the latest version. Correct me if I'm >> wrong here. >> >> I'm trying to get back to go1.14 to conduct further tests before making a >>

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Brian Candler
On Sunday, 27 June 2021 at 19:33:40 UTC+1 ro...@campbell-lange.net wrote: > Thank you for the pointers and the excellent video (actually by Bryan C. > Mills, it seems). > > Argh! My apologies to Bryan. I copied the link directly from my local bookmarks/notes file, and I had misattributed it

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Brian Candler
On Sunday, 27 June 2021 at 10:32:22 UTC+1 ro...@campbell-lange.net wrote: > By the way, as a golang newbie, it isn't clear to me when it is advisable > to > use a channel for locking as opposed to a mutex. Do people tend to use the > former? > > There is an absolutely excellent video on this

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Brian Candler
One way to be robust against this particular problem is to carry a pointer to a mutex, rather than embedding a mutex. https://play.golang.org/p/UPY7EBKSYl5 On Sunday, 27 June 2021 at 10:18:52 UTC+1 Brian Candler wrote: > > Shouldn't that result in a panic, even without -race? &g

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Brian Candler
> Shouldn't that result in a panic, even without -race? It's not *guaranteed* to panic when you make concurrent accesses to the same map (hence the point of the race checker). And having two structs refer to the same map is no different to having two variables refer to the same map. For

Re: [go-nuts] Re: Upgrade to Go1.16 from Go1.14 broke my query

2021-06-27 Thread Brian Candler
On Sunday, 27 June 2021 at 03:27:28 UTC+1 hugh@gmail.com wrote: > I agree. So far, I've Installed Go1.15, reinstalled the Firebird library. Which version? The latest tagged version (v0.9.1) or the tip of the master branch? Having said that: the commit

Re: [go-nuts] Recomended GOPROXY (or not) for Open Source projects?

2021-06-26 Thread Brian Candler
If we're talking about an OSS project here, then having one of the dependencies vanish is "just" a case of replacing that dependency in the project. That is, it's part of normal project maintenance, in the same way that if a severe security issue were discovered in a dependency, you'd have to

[go-nuts] Re: Specify local IP address in net.DialTCP throwing error bind: address already in use

2021-06-22 Thread Brian Candler
I'm afraid the question isn't related to the Go programming language at all. It's related to the operating system you're running on - which as far as I can see, you haven't mentioned. It's whatever the underlying system calls and TCP stack do. On Tuesday, 22 June 2021 at 16:40:16 UTC+1

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread Brian Candler
https://xkcd.com/386/ :-) On Tuesday, 22 June 2021 at 07:19:19 UTC+1 axel.wa...@googlemail.com wrote: > On Tue, Jun 22, 2021 at 1:23 AM Steven Penny wrote: > >> OK, so all all these decades of experience, why cant anyone produce a >> small >> program to demonstrate the problem? > > > I must

[go-nuts] Re: how to consume API using Golang

2021-06-19 Thread Brian Candler
You don't need to build and encode the Authorization header yourself - you can use Request.SetBasicAuth . Building it yourself is fine too, if you do it right - google "go http authorization basic" for some examples. Your code has a lot

[go-nuts] Re: unexpected behavior http.MaxBytesReader & streaming response

2021-06-19 Thread Brian Candler
Ah I get it now: it's due to application starting to send a response before the request has been completely received, as per the response to your ticket which links to https://github.com/golang/go/issues/15527 On Saturday, 19 June 2021 at 11:15:34 UTC+1 Brian Candler wrote: > H

[go-nuts] Re: unexpected behavior http.MaxBytesReader & streaming response

2021-06-19 Thread Brian Candler
Here is a variation on your program, removing json.Encoder from the equation: https://play.golang.org/p/ACS_n1yNJfQ It works as shown, but if you uncomment the commented-out fmt.Fprintf, it fails. (macOS, go1.16.5) This is indeed weird. As far as I can see, the only way MaxBytesReader

Re: [go-nuts] Representing Optional/Variant Types Idiomatically (or not)

2021-06-17 Thread Brian Candler
On Thursday, 17 June 2021 at 09:02:48 UTC+1 axel.wa...@googlemail.com wrote: > >> How would you go about modelling this type in Go? >> > > Either using an interface, or by having two pointer-fields and only > setting one. > I'd just add for clarity: in Go an interface value is also something

[go-nuts] Re: Question about container/heap

2021-06-13 Thread Brian Candler
On Sunday, 13 June 2021 at 16:09:48 UTC+1 kee...@gmail.com wrote: > For my heap, I never had to Push or Pop, I only had to initialize the heap > and repeatedly "Fix" the top element of the heap. As it turns out the Init > and Fix functions only use the 3 sorting methods of the heap. They

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Brian Candler
When you assign a regular (non-pointer) value to an interface variable, it does take a copy of that value: https://play.golang.org/p/XyBREDL4BGw Compare with what happens when the interface contains a pointer: https://play.golang.org/p/UpZnHS0xDU1 As to whether the value is copied when you copy

Re: [go-nuts] Re: Ignore /vendor by default in polyglot repository

2021-06-04 Thread Brian Candler
I don't suppose you could move all the go code down a level, say into a "go" subdirectory of the repo, including the go.mod file? On Friday, 4 June 2021 at 17:44:37 UTC+1 manlio@gmail.com wrote: > On Friday, June 4, 2021 at 6:24:28 PM UTC+2 Jacob Vosmaer wrote: > >> On Thu, Jun 3, 2021 at

Re: [go-nuts] Re: Is this a bug ?

2021-06-04 Thread Brian Candler
> var a byte = (1 << x) / 2 > var b byte = (1 << y) / 2 That one's more obvious [once the parentheses are added], and I find it helps understand the float case as well. x is a constant, so 1 << x is calculated at compile time to arbitrary precision, and then converted to a byte. That's fine.

[go-nuts] Re: Is this a bug ?

2021-06-03 Thread Brian Candler
Weird. It simplifies to this: https://play.golang.org/p/OsOhRMC6kBu On Thursday, 3 June 2021 at 10:08:22 UTC+1 Jamil Djadala wrote: > > https://groups.google.com/g/golang-nuts > > package main > > import ( > "fmt" > ) > > func main() { > const aa int = 0 > var a int >

[go-nuts] Re: json unmarshalling troubles

2021-06-02 Thread Brian Candler
> If you try using switch value.(type) instead of using reflect, bool will be reported as int, fyi, so using reflect here. Could you explain that a bit further please? A type switch seems to work OK for me, with no reflect. https://play.golang.org/p/TBH5zKYnG4G -- You received this message

Re: [go-nuts] Test driving Go 2?

2021-06-01 Thread Brian Candler
There is also https://go2goplay.golang.org/ (which is perhaps misleadingly named, given that there are no plans for Go 2) On Tuesday, 1 June 2021 at 17:54:05 UTC+1 Ian Lance Taylor wrote: > On Tue, Jun 1, 2021 at 9:39 AM Torsten Bronger > wrote: > > > > Is there already a possibility to give a

Re: [go-nuts] Json to CSV parsing with raw Data

2021-05-28 Thread Brian Candler
Another approach: https://play.golang.org/p/vTVE3nrGs86 On Friday, 28 May 2021 at 19:00:11 UTC+1 seank...@gmail.com wrote: > maybe something like https://play.golang.org/p/z-Yp4bh7jto > > On Friday, May 28, 2021 at 6:59:34 PM UTC+2 manlio@gmail.com wrote: > >> On Friday, May 28, 2021 at

Re: [go-nuts] How to restore ignored signals

2021-05-21 Thread Brian Candler
If I understand rightly, it boils down to this: https://play.golang.org/p/vYlTzluIuBL The documentation does say "Reset undoes the effect of any prior calls to Notify for the provided signals", without mentioning any effect on Ignore'd signals. On

[go-nuts] Re: Guarantee tcp pkt delivery

2021-05-19 Thread Brian Candler
For detailed explanation from a TCP and sockets point of view, see: https://stackoverflow.com/questions/11436013/writing-to-a-closed-local-tcp-socket-not-failing (This is described the opposite way round, where the client closes the socket then the server tries to write, but it's the same:

Re: [go-nuts] How to cast a multi-value?

2021-05-19 Thread Brian Candler
On Tuesday, 18 May 2021 at 21:09:18 UTC+1 Amnon wrote: > My understanding was that a string had a pointer and a length > Yes indeed - sorry my brain was disengaged :-) > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] How to cast a multi-value?

2021-05-18 Thread Brian Candler
Assigning a string value to another variable doesn't double the memory usage. A value of type string consists of a pointer, a length, and a capacity, and only these are copied - so you get another copy of the pointer, pointing to the same data buffer. > -- You received this message because

Re: [go-nuts] How can I check error types of gRPC calls?

2021-05-18 Thread Brian Candler
It's an alias for this: https://pkg.go.dev/google.golang.org/grpc/internal/status#Status So it should have Code() and Detail() methods. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: Strange benchmark results

2021-05-16 Thread Brian Candler
On Sunday, 16 May 2021 at 08:07:17 UTC+1 tapi...@gmail.com wrote: > > you don't provide memory allocation statistics, > > There are no surprises in memory allocation statistics so I didn't mention > them. > > I think it is relevant, because your different functions return slices of different

[go-nuts] Re: Strange benchmark results

2021-05-15 Thread Brian Candler
With go version go1.16.3 darwin/amd64 (macOS 10.14.6), and after changing N/5 to N/2, I can't reproduce either. $ go test . -bench=. -benchtime=3s N = 1615119 goos: darwin goarch: amd64 pkg: bm cpu: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz Benchmark_InsertOneline-4

[go-nuts] Re: Still "missing" priority or ordered select in go?

2021-05-12 Thread Brian Candler
On Wednesday, 12 May 2021 at 08:40:36 UTC+1 Haddock wrote: > I once implemented something to solve the same problem in Java. So I have > a high priority queue (hq) and a low priority queue (lq). Whenever an item > is atted to the hq a token is also added to some associated high priority >

[go-nuts] Re: encoding/json: add FlexObject for encoding/decoding between JSON and flex Go types.

2021-05-10 Thread Brian Candler
That is true, you need a separate wrapper object for decoding (the one with json.RawMessage). But the wrapped objects are the same. -- 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

[go-nuts] Re: encoding/json: add FlexObject for encoding/decoding between JSON and flex Go types.

2021-05-09 Thread Brian Candler
On Sunday, 9 May 2021 at 13:30:59 UTC+1 Ally Dale wrote: > But the way of [generate a sample JSON]( > https://github.com/vipally/glab/blob/master/lab27/json_raw_test.go#L38) > in this case looks ugly: > > It doesn't have to be as ugly as that: https://play.golang.org/p/BUjUNtJP_rG -- You

[go-nuts] Re: problem with starting to use pug/jade

2021-05-08 Thread Brian Candler
Note: if "go get github.com/Joker/jade/cmd/jade" gives this error: go get: module github.com/Joker/jade@upgrade found (v1.0.0), but does not contain package github.com/Joker/jade/cmd/jade Then see this issue: https://github.com/Joker/jade/issues/38 I think you're supposed to use "go install"

[go-nuts] Re: problem with starting to use pug/jade

2021-05-08 Thread Brian Candler
You need to get to the point where typing "jade" at the shell runs the jade executable, like this . Did you install the jade executable? The error says the jade executable was not found in your search

[go-nuts] Re: How to merge two Unstructured objects type ?

2021-05-03 Thread Brian Candler
On Sunday, 2 May 2021 at 19:18:43 UTC+1 mmahmo...@gmail.com wrote: > > https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured#section-documentation > > I am looking for something like the following > func mergeObjects(obj1 *uns.Unstructured, obj2 *uns.Unstructured) >

Re: [go-nuts] Why fmt.Println(math.Sqrt2) gives ...0951 not ...0950?

2021-05-01 Thread Brian Candler
Remember that while a constant may have unlimited precision, when you call fmt.Println() then it will get converted to a float64 value to be passed as an argument. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

[go-nuts] Re: Accidentally released a v1.0.0 for my package, how do I go back from there here?

2021-05-01 Thread Brian Candler
Can you give the URL of the repo? -- 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 this discussion on the web

Re: [go-nuts] Re: Multi-word Project Name

2021-04-29 Thread Brian Candler
Sure. In the OP's given path "github.com/username/sherlock-server", if it provides either "package sherlock" or "package server" it's not too bad. Thanks for pointing me to goimports. That does indeed rewrite the example as import ( "fmt" foo "example.com/my/module/with-a-very-weird-name" )

Re: [go-nuts] Re: Multi-word Project Name

2021-04-29 Thread Brian Candler
P.S. I don't really recommend this, since you can't tell by inspection of main.go which import provides "foo.Greeting". And I'm struggling to think of any real-world examples where I've seen this used. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Re: Multi-word Project Name

2021-04-29 Thread Brian Candler
> Guess by "even if it wasn't" you mean "even if it wasn't top level and was exporting functionality" I think he means in general, you can do this: // go.mod says "module github.com/my/module/with-a-very-weird-name" package foo ... and when you import it, you still get a package "foo". That's

Re: [go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-27 Thread Brian Candler
On Tuesday, 27 April 2021 at 07:28:39 UTC+1 christoph...@gmail.com wrote: > It seam that C is wrong on this one and Go is right. The rationale is that > a NaN must propagate through operations so that we can detect problems > (avoid silent NaNs). See https://en.wikipedia.org/wiki/NaN > > Thus

[go-nuts] Re: what is a &^= b means?

2021-04-24 Thread Brian Candler
More or less equivalent to: a = a & (^b) where & is bitwise AND operator, and ^ is bitwise NOT operator. Upshot: any bit which is 1 in 'b' causes the corresponding bit in 'a' to be set to 0. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Purpose of TimeoutHandler

2021-04-24 Thread Brian Candler
That works too. Err() is guaranteed to return non-nil, either if the context was explicitly cancelled or its deadline was exceeded. -- 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

[go-nuts] Re: unable to install go1.1.2

2021-04-22 Thread Brian Candler
On Thursday, 22 April 2021 at 13:45:52 UTC+1 manlio@gmail.com wrote: > The solution was to simply remove the `-Werror` warning in cmd/dist and > disable CGO with CGO_ENABLED=0 > Glad it's working. That's also one of the things you'll find

[go-nuts] Re: unable to install go1.1.2

2021-04-22 Thread Brian Candler
Ah well, if it's just for fun then please knock yourself out, but don't be surprised if compiling old code on new compilers turns up problems like this. My suggestion is firing up a VM containing a Linux distribution of similar vintage (say Ubuntu 12.04) and compile inside that. Aside: you'd

[go-nuts] Re: unable to install go1.1.2

2021-04-22 Thread Brian Candler
Could you describe what platform you are trying to build on? Also, could you explain why you need to build such an ancient version? There may be a better solution to whatever you're trying to do. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

[go-nuts] Re: go build ./... will produce a binary of one and only one main package is found

2021-04-21 Thread Brian Candler
On Tuesday, 20 April 2021 at 20:28:56 UTC+1 manlio@gmail.com wrote: > And I notice only now that you can do `go build -o "" ./...`. > But does that work? See https://github.com/golang/go/blob/master/src/cmd/go/internal/work/build.go#L374-L377 Testing with go 1.16.3 shows that it doesn't:

[go-nuts] Re: go build ./... will produce a binary of one and only one main package is found

2021-04-20 Thread Brian Candler
I agree with the OP: it would be less surprising if "go build ./..." always did build and store the artefacts, and there were a separate flag to discard them. Currently, "go build ./..." discards the build artefacts under certain conditions, see this example

[go-nuts] Re: Autocert failure with HTTP handler

2021-04-20 Thread Brian Candler
Another way to look at it: https://play.golang.org/p/8c3EgpiXS8e > -- 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

[go-nuts] Re: Autocert failure with HTTP handler

2021-04-19 Thread Brian Candler
As far as I understand it: "go foo(bar, baz)" evaluates all the arguments first, *then* starts a goroutine with function foo(val1, val2) Since http.ListenAndServe() never returns [unless it fails to start], it never gets as far as starting a goroutine for log.Fatal, and therefore cannot

[go-nuts] Re: Is there a bug in the command "go list -deps -json ./..."?

2021-04-19 Thread Brian Candler
Can you explain exactly which values you think are wrong, and what values they should have? I can't see any problem with those. Examples I checked: github.com/Azure/go-autorest/autorest/azure ^module (there is a go.mod here

[go-nuts] Re: go build ./... will produce a binary of one and only one main package is found

2021-04-19 Thread Brian Candler
In short, yes this is as intended, although somewhat obscure. The documentation is here : *"When compiling a single main package, build writes the resulting executable to an output file named after the first source file ('go

[go-nuts] Re: Purpose of TimeoutHandler

2021-04-19 Thread Brian Candler
Your inner request handler needs to use the request context to cancel its work. package main import ( "log" "net/http" "time" ) type foo struct{} func (f foo) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Print("New request") for i := 0; i < 10; i++ { select { case

Re: [go-nuts] Re: go routines not being deallocated

2021-04-18 Thread Brian Candler
This is memory allocated as reported by go itself, not by the OS. -- 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

[go-nuts] Re: go routines not being deallocated

2021-04-18 Thread Brian Candler
What do you mean by "It won't work on the playground"? It runs for me. Are you saying you get different results when running locally? If so, what version of go are you running locally, on what platform, and what do you see? Or are you saying the problem is really with something like this?

[go-nuts] Re: 9% performance loss with 1.16.3 vs. 1.15.11

2021-04-18 Thread Brian Candler
Could you compare with go 1.15 running with GODEBUG=madvdontneed=1 ? That's now standard behaviour in 1.16. -- 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

Re: [go-nuts] Getting a Go executable(hugo) to run Intel Galileo/Quark

2021-04-16 Thread Brian Candler
Can you add a swapfile? That could rule out low RAM as the problem, even if it's very inefficient. Aside: 127MB does sound like a very large binary, compared to what the standard go toolchain produces. The official hugo amd64 binary is about 44MB: $ tar -tvzf hugo_0.82.0_Linux-64bit.tar.gz

Re: [go-nuts] Case for Cond.WaitTimeout()

2021-04-13 Thread Brian Candler
Bryan Mill's presentation on go concurrency patterns is well worth watching all the way through: https://www.youtube.com/watch?v=5zXAHh5tJqQ There are lots of code snippets which are directly relevant to what you're trying to do, e.g. from 20:48 is a queue with Get, and 21:59 a queue with

<    1   2   3   4   5   6   7   8   >