[go-nuts] Re: Logging in to web services

2021-10-12 Thread Brian Candler
eful results. On Tuesday, 12 October 2021 at 10:11:21 UTC+1 Brian Candler wrote: > The problem is that you have a global variable giving "the currently > logged in user": > userDefault = checkUser > > Hence everyone sees the same user. > > The way to deal with th

[go-nuts] Re: Logging in to web services

2021-10-12 Thread Brian Candler
The problem is that you have a global variable giving "the currently logged in user": userDefault = checkUser Hence everyone sees the same user. The way to deal with this is generally that when a user authenticates, you set a cookie in their session. For every request, the cookie gives their

[go-nuts] Re: generics: how to repeat type in parameters

2021-10-09 Thread Brian Candler
. On Saturday, 9 October 2021 at 18:38:00 UTC+1 Brian Candler wrote: > "coder" and "tester" are two different defined types, but function Print > is defined to take two arguments of the same type. > > Even though they implement the same interface, they are not t

[go-nuts] Re: generics: how to repeat type in parameters

2021-10-09 Thread Brian Candler
"coder" and "tester" are two different defined types, but function Print is defined to take two arguments of the same type. Even though they implement the same interface, they are not the same type. I'd say you want to interfaces *instead* of generics: https://go2goplay.golang.org/p/rPU46HWvZJu

[go-nuts] Re: unmarshal xml to a struct edmx:Edmx

2021-10-09 Thread Brian Candler
commenting out the "XMLName" member of the struct and running it again. On Saturday, 9 October 2021 at 12:57:35 UTC+1 Brian Candler wrote: > Firstly, you can name the struct fields whatever you like, except it needs > to start with a capital letter. It doesn't have to match

[go-nuts] Re: unmarshal xml to a struct edmx:Edmx

2021-10-09 Thread Brian Candler
Firstly, you can name the struct fields whatever you like, except it needs to start with a capital letter. It doesn't have to match the XML element name at all. Secondly, what you're looking at here is an XML *namespace* declaration. The special attribute xmlns:edmx="http://docs.oasis-open.org

Re: [go-nuts] Can generics help me make my library safer?

2021-10-06 Thread Brian Candler
FWIW, I like the idea of being able to write direct SQL and still have some static type checking. ORMs are OK for simple "get" and "put", but I have been bitten so many times where I *know* the exact SQL I want for a particular query, but the ORM makes it so damned hard to construct it their w

[go-nuts] Re: unable get the json response values through json.Unmarshal()

2021-10-03 Thread Brian Candler
1. Check the error result code from json.Unmarshal. It will tell you when something is wrong. 2. However in your case, it's much simpler. The JSON contains an element {"content": ... } but your type Rs doesn't have a "Content" member. Therefore, it doesn't match any element in the incoming J

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Brian Candler
On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: > The documentation <https://pkg.go.dev/encoding/json#Unmarshal> says it > prefers exact match over case-insensitive, but example 3 contradicts that. > It seems to be last-match that wins. > > I realise n

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Brian Candler
Wow, I didn't realise until now that Unmarshal does case-insensitive matching: https://play.golang.org/p/wddrcakLvr_Q The documentation says it prefers exact match over case-insensitive, but example 3 contradicts that. It seems to be last-match that

Re: [go-nuts] Type Parameters Proposal, few unimportant questions

2021-09-23 Thread Brian Candler
On Thursday, 23 September 2021 at 18:07:19 UTC+1 kziem...@gmail.com wrote: > Understand this whole text without running code in compiler is just above > my mediocre (at best) programming skills. Compilers errors are one of mine > favorite teachers. You can try out examples online in the go2 pl

[go-nuts] Re: What is up with memo.com?

2021-09-21 Thread Brian Candler
I've seen the same too. Sadly memo.com don't provide any opt-out link in their messages. Based on IP addresses in headers, the parent appears to be https://joylabs.com/. I tried contacting them via their web contact form, but have had no response. On Tuesday, 21 September 2021 at 17:48:20 U

[go-nuts] Re: setuid root

2021-09-20 Thread Brian Candler
Try: cmd:=exec.Command("id") If it's definitely running as root then it could be other system-level restrictions: SELinux for example. If so, "dmesg" output may give you a clue, logging the policy violation. On Monday, 20 September 2021 at 16:20:39 UTC+1 Tamás Gulácsi wrote: > You mean "chown

[go-nuts] Re: Idea extending xerror.As

2021-09-19 Thread Brian Candler
outer function. https://go2goplay.golang.org/p/h6ZRnqM5cRx On Sunday, 19 September 2021 at 18:36:43 UTC+1 Haddock wrote: > Brian Candler schrieb am Sonntag, 19. September 2021 um 13:38:49 UTC+2: > >> Also, I may be missing the point, but does the following do what you want? >> http

Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread Brian Candler
t the > value. So `fmt` uses its reflect-based printing for structs. > > On Sun, Sep 19, 2021 at 1:44 PM Brian Candler wrote: > >> However, the zero value itself is printable. It's only a pointer to the >> zero value which panics. >> https://play.golang.org/p/Lh

Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread Brian Candler
7;s expected. The panic > happens because it tries to stringify the underlying error, which is nil. I > would say the creation of a packages error types are the purview of that > package. I don't think you can, generally, expect that their zero values > are valid. > > On Sun

[go-nuts] Re: Idea extending xerror.As

2021-09-19 Thread Brian Candler
Also, I may be missing the point, but does the following do what you want? https://play.golang.org/p/86DQD5QMbJ3 _, err := os.Open("non-existing") if pe := (&os.PathError{}); errors.As(err, &pe) { fmt.Println("Failed at path:", pe.Path) } On Sunday, 19 September

[go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread Brian Candler
Is this intentional? https://play.golang.org/p/ylXlkOq2sID Result I get in browser: &{0} %!v(PANIC=Error method: runtime error: invalid memory address or nil pointer dereference) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Re: Idea extending xerror.As

2021-09-19 Thread Brian Candler
I notice at least three things from your proposed syntax: 1. Passing a *type* as an argument ("os.PathError"), rather than a *value of a type* 2. A control structure. This might involve passing a block of code as a hidden argument (like blocks in Ruby), or some sort of macro expansion. 3. The s

Re: [go-nuts] Z algorithm in string package

2021-09-18 Thread Brian Candler
A tradeoff with this algorithm is the extra memory allocation required. Say you're using int32 to represent the substring length, then a string of length N and pattern length P needs a temporary memory allocation of size 4N+4P+4. Hence I'm not sure this is a good fit for string.Index, especial

[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" if

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 to

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 thi

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 ( "key

[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 "golang-

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

2021-09-04 Thread Brian Candler
changes in 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. &g

[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? If

Re: [go-nuts] Managing perpetually running goroutines

2021-08-30 Thread Brian Candler
y myself). > > If that's too broad a question, 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

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 h

[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 the

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 https://www.reddit.com/r/golang/comme

[go-nuts] Re: database/sql doubt

2021-08-12 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 := &Zoo > Display2(vp) # vp is copied > > Correction: vp := &v or vp := &Zoo{...} > These are identical, consistent behaviours. > >

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 > val

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

2021-08-09 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. On

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): https://github.com/golang/

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 u

[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 usi

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 kubernet

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

2021-07-28 Thread Brian Candler
ou see ("small 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

[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
termine 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 th

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

2021-07-21 Thread Brian Candler
r > 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.

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. > > Wit

[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 golang.org/x/tools/go/package

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 start

[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 w

[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 > can

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: https://blog.golang.org

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

2021-07-08 Thread Brian Candler
pretty different from Python's, you will have a better understanding >>>> 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 b

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

2021-07-07 Thread Brian Candler
u got them! 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 whic

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 75?

[go-nuts] Re: Stack growing is inefficient

2021-06-30 Thread Brian Candler
pi...@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

[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 th

[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 s

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 subscribed

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

2021-06-28 Thread Brian Candler
logError(err.Error()) > return > } > tests = append(tests, t) > } > err = rows.Err() > if err != nil { > respondWithError(w, http.StatusBadRequest, err.Error()) > logError(err.Error()) > return > } > respondWithJSON(w, http.StatusOK, tests) > > } > > *T

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

2021-06-28 Thread Brian Candler
d 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

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 t

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 t

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? &

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 the

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 chanda

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 say

[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 o

[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 in

[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 don'

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 6:

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 > fmt.Println

[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 be

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 6:26:

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 Frida

[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: onc

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 y

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 "golang-nuts"

[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 cap

[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 > token

[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 it

[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 receiv

[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" rat

[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 path

[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) > (*uns.Unstruct

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 a

[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 vis

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" )

<    1   2   3   4   5   6   7   8   >