[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread Martin Schallnahs
Hi Brian, thanks for checking out, yes that I wanted also to write you. We need it currently in our CI as some dependency scanner tool does not work with the "go X.Y.Z." syntax, but I tried, and for my problem it did not was the cause. > If a test fails, I would expect it to terminate with an

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread 'Brian Candler' via golang-nuts
I found the solution to the "toolchain not available" problem: put "go 1.22.0" instead of "go 1.22" in go.mod. Clues picked up from #62278 . It's confusing for people who've been using go for a while though, when go.mod used to contain "go X.Y" and it

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-08 Thread 'Brian Candler' via golang-nuts
Is it a bug or exepected behaviour? If a test fails, I would expect it to terminate with an error (exit code 1 in this case). If I run your reproducer locally (not in Docker) with the modified TestHelloer, it works fine(*) and gives me an exit code of 0: % go test -v ./...

[go-nuts] Re: templates not working for me

2024-02-07 Thread joseph.p...@gmail.com
Ok, Variable substitution doesn't seem to work in an included template file. Is that a known limitation? On Saturday, February 3, 2024 at 11:40:40 PM UTC-8 joseph.p...@gmail.com wrote: > I'm goofing around with GIN and trying some examples. I can't get > templating to work for me. > > File

[go-nuts] Re: Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-07 Thread Martin
I need to add: In the post the reproducer test is of course to short, so the test show that it fails all the time. But that triggers the problem anyway. Better would be this: func TestHelloer(t *testing.T) { want := "Hello, world!" got := Helloer() if got != want {

Re: [go-nuts] Re: Changing PWD ruins test caching

2024-02-07 Thread Kevin Burke
Sorry for slow reply. We are using Alpine, which I don't think is either of those flavors. I discovered this by enabling GODEBUG=gocachehash=1, running the tests twice, and then checking the diff between the two test runs. On Tue, Nov 28, 2023 at 11:57 AM 'Bryan C. Mills' via golang-nuts <

[go-nuts] Go 1.22.0: Alpine: go test with coverage works but returns exit status 1

2024-02-07 Thread Martin
I am using the new `golang:1.22.0-alpine3.19` Alpine image to build and test a Golang 1.22.0 application. The test uses coverage like that `go test -v ./... -coverprofile=coverage.out -coverpkg=./internal/... -covermode count`. The test command seems to work fine, but the exit status is 1. The

[go-nuts] 1.22.0 ServeMux HandleFunc infinite loop

2024-02-07 Thread Péter Szarvas
Hello, I noticed if you set up a route like /something/{id}/{$}, it results in an infinite loop if I navigate to /someting/ (with the trailing slash). I got a redirect to Location: /something/, and so on. Finally the page breaks after multiple rounds. Example: mux := http.NewServeMux()

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread Robert Griesemer
On Wed, Feb 7, 2024 at 9:58 AM Jason E. Aten wrote: > Thanks Robert. Succeess: I see the latest go1.22 spec now on > https://go.dev/ref/spec > > Minor nit: As Rob pointed out, the year in the sub-title is off by one. > (It says Jan 30, 2023, while almost surely the author of the update meant >

[go-nuts] Re: Error on installing package

2024-02-07 Thread Jason Phillips
There's an application in the "internal/play" folder of that module. You can install it via: go install 154.pages.dev/google/internal/play@v1.4.0 As for how to use it, I have no idea, you'll have to reach out to the maintainer if there's no documentation. On Wednesday, February 7, 2024 at

Re: [go-nuts] "yield" is backwards

2024-02-07 Thread mspre...@gmail.com
I see. I was thinking of it from the point of view of the author of this yield/consume function. From that party's perspective, this function expresses the consumption of the value, not its production. But since the new go lang feature will make that not an explicit function, that is not the

Re: [go-nuts] "yield" is backwards

2024-02-07 Thread Marvin Renich
* mspre...@gmail.com [240207 10:43]: > The go language is getting better and better for functional programming, > and I am here for it. I have enjoyed using APL, Scheme, Python. I was > excited to see https://go.dev/wiki/RangefuncExperiment . However, I am > puzzled by the choice to name the

[go-nuts] Re: Bound check optimization with "computed" index

2024-02-07 Thread 'Keith Randall' via golang-nuts
I'm not sure, but I suspect that the prove pass does not propagate known ranges through divides. On Tuesday, February 6, 2024 at 7:39:56 AM UTC-8 Leonard Mittmann wrote: > I am trying to optimize the loop performance by reducing the number of > bound checks. Inside the loop I compute a slice

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread Jason E. Aten
Thanks Robert. Succeess: I see the latest go1.22 spec now on https://go.dev/ref/spec Minor nit: As Rob pointed out, the year in the sub-title is off by one. (It says Jan 30, 2023, while almost surely the author of the update meant Jan 30, 2024). "The Go Programming Language Specification

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread Robert Griesemer
Spec is up-to-date at tip, now: https://tip.golang.org/ref/spec https://golang.org/ref/spec should be updated soon, too. Apologies for the confusion. - gri On Wed, Feb 7, 2024 at 8:11 AM Jason E. Aten wrote: > Thanks Peter. I see the latest spec at tip.golang.org. > > p.s. Go Team: At least in

Re: [go-nuts] "yield" is backwards

2024-02-07 Thread 'Axel Wagner' via golang-nuts
I'm not sure what you mean. The `yield` function does exactly the same as Python's `yield` statement and in fact, that's part of why the name was chosen. Compare Python: def vals(a): for v in a: yield v for x in vals([1,2,3]): print(x) With Go: func vals[T any](s []T)

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread Jason E. Aten
Thanks Peter. I see the latest spec at tip.golang.org. p.s. Go Team: At least in the UK, the page served from https://go.dev/ref/spec does not, at the moment, match that of https://tip.golang.org/ref/spec , so somebody may need to do an update (if not of origin server, maybe of CDN caches?)

[go-nuts] "yield" is backwards

2024-02-07 Thread mspre...@gmail.com
The go language is getting better and better for functional programming, and I am here for it. I have enjoyed using APL, Scheme, Python. I was excited to see https://go.dev/wiki/RangefuncExperiment . However, I am puzzled by the choice to name the function parameter that _receives_ a Seq's

[go-nuts] Re: Error on installing package

2024-02-07 Thread Smit K
How to use this 154.pages.dev/google@v1.4.0 On Tuesday, February 6, 2024 at 10:07:24 PM UTC+5:30 Jason Phillips wrote: > Perhaps you wanted "go get 154.pages.dev/goo...@v1.4.0 > "? > > On Tuesday, February 6, 2024 at 11:36:11 AM UTC-5 Jason Phillips wrote: >

[go-nuts] Group Cache Behaviour

2024-02-07 Thread Vallabh Chugh
Hi folks, Fairly new to the k8s world. I am using group cache .I run a go routine to fetch all set of pods for a deployment and update my group cache pool if there is a change every 60 second. The problem i see is if that if there is a change in the pool (pods added) and if the incoming

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread peterGo
Jason, File an issue with the Go release team to clean up the mess. Peter On Wednesday, February 7, 2024 at 7:12:08 AM UTC-5 Brian Candler wrote: > But the main point is, the canonical version published at > https://go.dev/ref/spec is still from Aug 2, 2023 > > On Wednesday 7 February 2024 at

Re: [go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-07 Thread Pedro Luis Guzmán Hernández
Thanks all, I'll continue to call it for now, since that's what most engineers on my team would expect in that situation, but I'll happily reconsider if some documentation gets added at some point. El miércoles, 7 de febrero de 2024 a las 0:44:13 UTC+1, Ian Lance Taylor escribió: > On Tue,

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread 'Brian Candler' via golang-nuts
But the main point is, the canonical version published at https://go.dev/ref/spec is still from Aug 2, 2023 On Wednesday 7 February 2024 at 12:02:28 UTC Rob Pike wrote: > Ha ha, someone forgot to change the year. It should read Jan 30, 2024. > > That's confusing. > > -rob > > > On Wed, Feb 7,

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread Rob Pike
Ha ha, someone forgot to change the year. It should read Jan 30, 2024. That's confusing. -rob On Wed, Feb 7, 2024 at 8:47 PM peterGo wrote: > Jason, > > The Go 1.22 source code says: > > "Subtitle": "Language version go1.22 (Jan 30, 2023)", > > Blame > > #569 9289b9c gri@*.***

Re: [go-nuts] Re: new range over int docs?

2024-02-07 Thread peterGo
Jason, The Go 1.22 source code says: "Subtitle": "Language version go1.22 (Jan 30, 2023)", Blame #569 9289b9c gri@*.*** 2024-01-31 16:40 [release-branch.go1.22] spec: clarify iteration variable type for range over integer Change-Id: I4f1d220d5922c40a36264df2d0a7bb7cd0756bac

Re: [go-nuts] Re: new range over int docs?

2024-02-06 Thread Jason E. Aten
On Wed, Feb 7, 2024 at 3:34 AM peterGo wrote: > You are reading a specification dated Version of Aug 2, 2023. The current > specification for Go 1.22 is dated as Modified Tue 06 Feb 2024 10:08:15 PM > EST. > Link? https://go.dev/ref/spec still gives me the Aug 2, 2023 spec, which is what the

[go-nuts] Re: new range over int docs?

2024-02-06 Thread peterGo
Jason, The Go specification "Length and capacity" section defines the len built-in function. Peter On Tuesday, February 6, 2024 at 11:36:21 PM UTC-5 peterGo wrote: > Jason, > > The Go 1.22 specification, in part, > > For statements with range clause > > A "for" statement with a "range" clause

[go-nuts] Re: new range over int docs?

2024-02-06 Thread peterGo
Jason, The Go 1.22 specification, in part, For statements with range clause A "for" statement with a "range" clause iterates through all entries of an array, slice, string or map, values received on a channel, or integer values from zero to an upper limit [Go 1.22]. For an integer value n,

[go-nuts] Re: new range over int docs?

2024-02-06 Thread peterGo
Jason, The Go Programming Language Specification is reference documentation. It is intended to be read very carefully in its entirety. You are reading a specification dated Version of Aug 2, 2023. The current specification for Go 1.22 is dated as Modified Tue 06 Feb 2024 10:08:15 PM EST. The

[go-nuts] new range over int docs?

2024-02-06 Thread Jason E. Aten
The release notes https://go.dev/doc/go1.22 refer to the spec here https://go.dev/ref/spec#For_range but I do not see any details about the new for i := range 10 statement there. This is strange. Have the docs simply not been updated yet? But I do see this oddly out of place statement, where

Re: [go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2024 at 6:29 AM Pedro Luis Guzmán Hernández wrote: > > Thanks Brian. That is an implementation detail though, so relying on it with > no mention in the documentation at all feels unsound. A Close method usually > means you have to defer it right after getting the resource, so I

[go-nuts] Go 1.22.0 is released

2024-02-06 Thread announce
Hello gophers, We have just released Go 1.22.0. To find out what has changed in Go 1.22, read the release notes: https://go.dev/doc/go1.22 You can download binary and source distributions from our download page: https://go.dev/dl/#go1.22.0 If you have Go installed already, an easy way to try

[go-nuts] Go 1.21.7 and Go 1.20.14 are released

2024-02-06 Thread announce
Hello gophers, We have just released Go versions 1.21.7 and 1.20.14, minor point releases. View the release notes for more information: https://go.dev/doc/devel/release#go1.21.7 You can download binary and source distributions from the Go website: https://go.dev/dl/ To compile from source

[go-nuts] Re: Error on installing package

2024-02-06 Thread Jason Phillips
Perhaps you wanted "go get 154.pages.dev/google@v1.4.0"? On Tuesday, February 6, 2024 at 11:36:11 AM UTC-5 Jason Phillips wrote: > There's no Go package at the root of that repo/module, and thus nothing to > install. "go install" only works on main packages. > > On Tuesday, February 6, 2024 at

[go-nuts] Re: Error on installing package

2024-02-06 Thread Jason Phillips
There's no Go package at the root of that repo/module, and thus nothing to install. "go install" only works on main packages. On Tuesday, February 6, 2024 at 8:34:07 AM UTC-5 Smit K wrote: > With this command: go install 154.pages.dev/goo...@v1.4.0 > > It

Re: [go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread fgergo
(This time reply to list. Sorry Brian.) On Tue, Feb 6, 2024 at 3:03 PM 'Brian Candler' via golang-nuts wrote: > > > Thanks! In addition to that, It also helps with code with upper limit > > memory-requirement, which fmt.Sprintf() can't. > > If you're processing data from untrusted sources, then

[go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread 'Brian Candler' via golang-nuts
Documentation could certainly be improved, since the Part.Close() method has literally no documentation. Whilst it does feel unsound, in practice I don't think the behaviour could be changed now without breaking the Go compatibility guarantee

[go-nuts] Bound check optimization with "computed" index

2024-02-06 Thread Leonard Mittmann
I am trying to optimize the loop performance by reducing the number of bound checks. Inside the loop I compute a slice index and access two slice indexes like this: j := i / 2 s[j+1] = i s[j] = i // <- I want to get rid of this bound check I assumed that I can get rid of the second bound

Re: [go-nuts] Embedding an interface with a function type

2024-02-06 Thread Victor Manuel Giordano
Thanks El mar, 6 feb 2024 a las 12:05, Ian Lance Taylor () escribió: > On Tue, Feb 6, 2024 at 6:43 AM Victor Manuel “Vitu” Giordano > wrote: > > > > I'm wondering why the language allow me to write something like this: > > > > type IncFunc func(a int) int > > > > type Incrementor interface { >

Re: [go-nuts] Embedding an interface with a function type

2024-02-06 Thread Ian Lance Taylor
On Tue, Feb 6, 2024 at 6:43 AM Victor Manuel “Vitu” Giordano wrote: > > I'm wondering why the language allow me to write something like this: > > type IncFunc func(a int) int > > type Incrementor interface { > IncFunc // <-- THIS is allowed > IncQuantity() int > } > > (RTR example here) > > I

[go-nuts] Embedding an interface with a function type

2024-02-06 Thread Victor Manuel “Vitu” Giordano
Hi Goperhs! How you doing? Hope just fine! I'm wondering why the language allow me to write something like this: type IncFunc func(a int) int type Incrementor interface { IncFunc *// <-- THIS is allowed* IncQuantity() int } (RTR example here ) I don't get

[go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread Pedro Luis Guzmán Hernández
Thanks Brian. That is an implementation detail though, so relying on it with no mention in the documentation at all feels unsound. A Close method usually means you have to defer it right after getting the resource, so I would have expected the docs to be more clarifying on its usage. El martes,

[go-nuts] Re: Do we need to call multipart.Part.Close

2024-02-06 Thread 'Brian Candler' via golang-nuts
https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/mime/multipart/multipart.go;l=325 All it does is read all the remainder of the part to io.Discard. So if you're sure you've read each part before moving onto the next one, it looks like you should be good. On Tuesday 6 February 2024

Re: [go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread 'Brian Candler' via golang-nuts
> Thanks! In addition to that, It also helps with code with upper limit > memory-requirement, which fmt.Sprintf() can't. If you're processing data from untrusted sources, then you probably ought to validate it first. > How to use a limiting > io.Writer with fmt.Sprintf()? How would this limit

[go-nuts] Do we need to call multipart.Part.Close

2024-02-06 Thread Pedro Luis Guzmán Hernández
multipart.Part, returned by multipart.Reader's NextPart method, have a Close() method. The only example here https://pkg.go.dev/mime/multipart#NewReader doesn't use the Close() method at all, so what's it purpose? Can we safely ignore it? The reason I'm asking is that, calling *defer

[go-nuts] Error on installing package

2024-02-06 Thread Smit K
With this command: go install 154.pages.dev/google@v1.4.0 It is not installing: [image: Screenshot 2024-02-06 180047.png] -- 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

Re: [go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread fgergo
On Tue, Feb 6, 2024 at 12:18 PM 'Brian Candler' via golang-nuts wrote: > > The C functions are mainly there to prevent overrunning already-allocated > buffers, which isn't an issue with Go. Thanks! In addition to that, It also helps with code with upper limit memory-requirement, which

[go-nuts] Re: snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread 'Brian Candler' via golang-nuts
The C functions are mainly there to prevent overrunning already-allocated buffers, which isn't an issue with Go. You could truncate the response: a := fmt.Sprintf("%s", "Blah blah blah")[0:10] You could use suitable precision specifiers: a := fmt.Sprintf("%.10s", "Blah blah blah")

[go-nuts] snprintf() in Go with at most constant memory requirement difference than snprintf(3)?

2024-02-06 Thread fgergo
C *nprintf(3) implementations stop the conversion when n is reached. I couldn't find a similar functionality in the standard library, what did I miss? If there isn't any, any idea how to implement that without reimplementing all format helpers? thanks! -- You received this message because you

Re: [go-nuts] evaluation of range expression in for-range loop

2024-02-05 Thread Tamás Gulácsi
Yes. If you manipulate the meaning of the index (i) or the length of the slice, then do it explicitly: for i := 0; i < len(a); i++ { if a[i] == 0 { //delete a[i]=a[0] a = a[1:] i-- } } For other methods, see https://go.dev/wiki/SliceTricks#filtering-without-allocating Shivansh

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-05 Thread 'Bryan C. Mills' via golang-nuts
In https://go.dev/issue/52545 we saw failures in the cmd/go tests on Google Cloud VMs due to a combination of a small number of available NAT ports and port exhaustion from TIME_WAIT connections, but the failure mode there was different (timed-out git commands rather than "cannot assign

Re: [go-nuts] evaluation of range expression in for-range loop

2024-02-05 Thread Shivansh Rustagi
Hi Guys, I had a question regarding: > On the other hand, if you have `for i, v := range a {` then the > expression *is* evaluated before the start of the loop. I have a code (https://goplay.tools/snippet/dMwD0_rEhkB) where I am ranging over a slice, and updating (removing the zeroth element

[go-nuts] templates not working for me

2024-02-03 Thread joseph.p...@gmail.com
I'm goofing around with GIN and trying some examples. I can't get templating to work for me. File inclusion works, but variable substitution does not. GOLANG version 1.20.12 package main import "github.com/gin-gonic/gin" import "net/http" // import "gorm.io/driver/sqlite" // import

Re: [go-nuts] Printf

2024-02-03 Thread Juan Mamani
Luca, thanks for your answerr El viernes, 2 de febrero de 2024 a la(s) 3:06:17 p.m. UTC-3, Luca Pascali escribió: > you forgot the \n in the printf format string > > without it, next is written right after the end of the printf > > > Psk > > Il ven 2 feb 2024, 17:56 Juan Mamani ha scritto: > >>

Re: [go-nuts] Printf

2024-02-03 Thread Juan Mamani
Kurtis, thanks for your reply. El viernes, 2 de febrero de 2024 a la(s) 2:12:55 p.m. UTC-3, Kurtis Rader escribió: > I think you're being confused by the lack of newlines in the output. Add > "\n" to the end of the printf format. > > On Fri, Feb 2, 2024 at 8:56 AM Juan Mamani wrote: > >> Hi

[go-nuts] Re: Golang formating of alternate form with zero padding

2024-02-03 Thread 'Brian Candler' via golang-nuts
Admittedly, C and Python work the same way, which is different to Go. #include int main(void) { printf("%07x\n", 42); printf("%0#7x\n", 42); printf("0x%07x\n", 42); return 0; } // Output 02a 0x0002a 0x02a On Wednesday 31 January 2024 at 13:56:07 UTC Brian Candler

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-02 Thread 'TheDiveO' via golang-nuts
carrier-grade NAT? On Friday, February 2, 2024 at 7:05:42 PM UTC+1 sprynger wrote: > In my case it might be an ISP problem, since this only happens to me when > I work from home. At work, the exact same project builds all at once > without any issues. > > A quinta-feira, 1 de fevereiro de 2024

Re: [go-nuts] Is this runtime.KeepAlive call really necessary

2024-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2024 at 10:05 AM Chong Yuan wrote: > > Here is the example in our gorocksdb: > > // Get returns the data associated with the key from the database. > > func (db *DB) Get(opts *ReadOptions, key []byte) (*Slice, error) { > >var ( > > cErr

Re: [go-nuts] Printf

2024-02-02 Thread Luca Pascali
you forgot the \n in the printf format string without it, next is written right after the end of the printf Psk Il ven 2 feb 2024, 17:56 Juan Mamani ha scritto: > Hi everybody! > > I was checking consistency behavior of fmt.Printf with some basic > samples. And for my surprise never

[go-nuts] Is this runtime.KeepAlive call really necessary

2024-02-02 Thread Chong Yuan
Here is the example in our gorocksdb: // Get returns the data associated with the key from the database. func (db *DB) Get(opts *ReadOptions, key []byte) (*Slice, error) { var ( cErr*C.char cValLen C.size_t

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-02 Thread sprynger
In my case it might be an ISP problem, since this only happens to me when I work from home. At work, the exact same project builds all at once without any issues. A quinta-feira, 1 de fevereiro de 2024 à(s) 21:07:03 UTC, TheDiveO escreveu: > Are you still using Debian 11 and the outdated

Re: [go-nuts] Printf

2024-02-02 Thread Kurtis Rader
I think you're being confused by the lack of newlines in the output. Add "\n" to the end of the printf format. On Fri, Feb 2, 2024 at 8:56 AM Juan Mamani wrote: > Hi everybody! > > I was checking consistency behavior of fmt.Printf with some basic > samples. And for my surprise never expected

[go-nuts] morbyd: a thin layer to easily build and run throw-away test containers, etc. in tests

2024-02-02 Thread 'TheDiveO' via golang-nuts
https://github.com/thediveo/morbyd is a thin layer on top of the standard Docker Go client to easily build and run throw-away test Docker images and containers, and running commands inside them. It features a function option API to keep the slightly excessive Docker API option parameters at

[go-nuts] Printf

2024-02-02 Thread Juan Mamani
Hi everybody! I was checking consistency behavior of fmt.Printf with some basic samples. And for my surprise never expected what I found. My context: OS: Linux, debian 8,9,10,11 Go version 1.21 What I was doing? Learning about fmt.Printf Expecting fmt.Printf behavior be the same output for

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-01 Thread 'TheDiveO' via golang-nuts
Are you still using Debian 11 and the outdated Debian docker.io package with Docker 18? What happens when you use a recent Docker, either 24.x or hot-off-the-press 25.0.1? And then build using a Go-Alpine base image? Do you still use Debian's broken Docker seccomp profile...? I'm on an IPv6

[go-nuts] Re: go mod download fails on docker for 1.20 (but not for 1.18)

2024-02-01 Thread Sebastiaan van der Meulen
Same issue here without solution. Hoping anyone finds one Op zondag 14 januari 2024 om 22:53:54 UTC+1 schreef Dmitry Anderson (4nd3rs0n): > I'm having the same problem. For now I just vendor modules to a project > modules and run without installing anything from the container, but also >

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Steven Hartland
Ignore that as it just triggers a panic if the limit is exceeded, however based on that I'm guessing it's not going to be possible. On Thu, 1 Feb 2024 at 19:01, Steven Hartland wrote: > Sounds sensible to me. > > I haven't read the entire thread, pun intended ;-), so just checking if > you

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Steven Hartland
Sounds sensible to me. I haven't read the entire thread, pun intended ;-), so just checking if you tried debug.SetMaxThreads ? On Thu, 1 Feb 2024 at 16:42, Steve Roth wrote: > Fair question. In their view, 25 threads per user is a sensible

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Nagaev Boris
Steve, I checked with strace and top -p (press H to see threads). It seems that Go can create few more threads than cores are given by taskset. For example, on an 8 core ARM machine in the cloud, I got these results on a program launching 100 goroutines utilizing a lot of CPU each. $ strace

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Bruno Albuquerque
In Go, you can not really limit the maximum number of threads that will be created. The runtime itself will create threads whenever needed for things like blocking CGO calls, garbage collection, network polling, etc. As I understand it, GOMAXPROCS only limits the number of threads that would be

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Steve Roth
Fair question. In their view, 25 threads per user is a sensible limit. Their mindset is based around single-threaded PHP. And for that reason among others, yes, switching providers is definitely something I will pursue. But that will be a long-term effort. Right now I'm looking for a

Re: [go-nuts] Re: help with thread limit

2024-02-01 Thread Steven Hartland
To be honest I would question if its a usable solution if they are limiting that low on threads, so is the fix to switch or have the provider increase the limit to a sensible number? On Thu, 1 Feb 2024 at 16:08, Steve Roth wrote: > Thanks to the people who suggested how to limit the number of

[go-nuts] Re: help with thread limit

2024-02-01 Thread Steve Roth
Thanks to the people who suggested how to limit the number of apparent cores. Unfortunately, doing that didn't solve the problem. I have the number of cores now limited to two — confirmed by checking runtime.NumCPU() — but the program is still trying to allocate more than 25 threads, and

[go-nuts] Re: [External] Differences between unmarshaling with encoding/json and encoding/protojson

2024-01-31 Thread Utkarsh Saxena
Do anyone git solution for this, having same issue? On Thursday, July 21, 2022 at 11:32:32 PM UTC+5:30 Darius Tan wrote: > Hi all, > Is there a comprehensive list of differences between how > json.NewDecoder(r.Body).Decode() and protojson.Unmarshal(req.Bytes(), > pbObj) unmarshals JSON

Re: [go-nuts] help with thread limit

2024-01-31 Thread Robert Engels
You can use cpuctrl or similar to limit the number of visible cores when you start the process. On Jan 31, 2024, at 8:43 PM, Steve Roth wrote:I am running Go code on a shared web hosting server from a major hosting company.  Using cgroups, they limit the number of threads any user can create to

[go-nuts] help with thread limit

2024-01-31 Thread Steve Roth
I am running Go code on a shared web hosting server from a major hosting company. Using cgroups, they limit the number of threads any user can create to 25. Up until a week ago, they had me running on a server with 24 cores, and everything worked fine. Now they've moved me to a new server with

Re: [go-nuts] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-31 Thread peterGo
Michael, Here is a Go solution to the OP's problem. It uses Go memory and Go pointers passed to C in Go memory point to pinned Go memory. https://go.dev/play/p/KLdenIesz1K Peter On Monday, January 29, 2024 at 12:21:18 PM UTC-5 Michael Knyszek wrote: > Thanks for the reproducer. I think I've

[go-nuts] Re: Golang formating of alternate form with zero padding

2024-01-31 Thread 'Brian Candler' via golang-nuts
https://pkg.go.dev/fmt#hdr-Printing The '#' means you want the alternate format with the 0x prepended, and the '7' means you want the number itself padded to 7 digits x := fmt.Sprintf("%07x", 42) // 02a y := fmt.Sprintf("%0#7x", 42) // 0x02a z := fmt.Sprintf("0x%07x", 42) //

[go-nuts] Golang formating of alternate form with zero padding

2024-01-31 Thread Lukas Toral
Hello, I am working on code that formats strings. I have an issue with formatting the alternate form with zero padding of signed hexadecimals. I have a format string like this: "%#07x", I would expect the zero padding to make sure the total width is 7. However, when I format the string using

[go-nuts] Re: discrepancy between goal heap size and NextGC

2024-01-30 Thread 'Michael Knyszek' via golang-nuts
838103616 bytes is 799 MiB (Mebibytes, the power-of-two-based prefix), which matches GC 13. (Note that the computation for the heap goal just divides by 1<<20, or 1 MiB.) The discrepancy in GC count is probably due to the fact that the GC count value reported by the GC trace is *after* the

[go-nuts] Re: array index not starting at 0

2024-01-30 Thread 'Michael Knyszek' via golang-nuts
I see that you're on Windows. The clock granularity on Windows is really coarse (15 ms) because AFAIK there are no fast fine-grained OS-level clocks available. There are fine-grained clocks, but they're heavyweight. They're too heavyweight for many situations in the runtime, but honestly,

Re: [go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread Jason Phillips
More generally, the input and output of encoding/json need not be a file at all. On Tuesday, January 30, 2024 at 10:54:57 AM UTC-5 Brian Candler wrote: > By the definition of "3.403 Text File > " > > then

[go-nuts] Re: array index not starting at 0

2024-01-30 Thread Leah Stapleton
Is it possible that some PauseNs numbers are so small that they're rounded down to 0? On Monday, January 29, 2024 at 9:45:32 AM UTC-5 Leah Stapleton wrote: > go version go1.21.5 windows/amd64 > > There have been 9 garbage collections according to NumGC and also the > PauseEnd array; However,

Re: [go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread 'Brian Candler' via golang-nuts
By the definition of "3.403 Text File " then no, because a JSON file can have arbitrarily long lines. Note also: "Although POSIX.1-2017 does not distinguish between text files and binary files (see the ISO C

[go-nuts] Re: discrepancy between goal heap size and NextGC

2024-01-30 Thread Michael Mitchell
Might it have something to do with the comment in mgc.go about how the increment of memstats.numgc differs from the increment of GC cycles for gctrace? memstats.numgc seems to get incremented earlier (after mark termination) whereas gctrace waits until the sweep is done. // cycles is the

Re: [go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread Javier Marti
So, as per the link that I sent, a json file is not a text file, right? is just a file, I want to have this clear thanks On Tue, Jan 30, 2024 at 3:50 PM 'Brian Candler' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The JSON spec does not require any whitespace after the object,

[go-nuts] Re: Is encoding/json POSIX compatible?

2024-01-30 Thread 'Brian Candler' via golang-nuts
The JSON spec does not require any whitespace after the object, newline or otherwise. And POSIX does not require that files end with a newline. Maybe you are thinking of another spec, like https://jsonlines.org/ - but that's not part of JSON. On Tuesday 30 January 2024 at 14:16:35 UTC Xabi

[go-nuts] Is encoding/json POSIX compatible?

2024-01-30 Thread Xabi Martí
I'm writing a program that uses enconding/json and when writing the files I see that it doesn't add a newline character at the end of the file, according to https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 it is supposed that a line is: 3.206 Line A

[go-nuts] Bad code contribution experience

2024-01-29 Thread mr....@gmail.com
I want to vent my frustration. The experience of contributing has been unpleasant for me. I have noticed that similar fixes are prioritized and merged faster, while I spent time resolving the issue and reporting it, but it did not receive an effective merge. Although it was during the freeze

Re: [go-nuts] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-29 Thread 'Michael Knyszek' via golang-nuts
Thanks for the reproducer. I think I've puzzled out what's going wrong and it's pretty subtle. TL;DR: You can work around this by either calling `calloc` or just allocating `inRows` as Go memory and pinning that as well. The latter will be safer and faster overall. It's not totally clear to me at

[go-nuts] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-29 Thread peterGo
Michael, The OP appears to have lost interest in debugging. Here's my minimal, reproducible example that produces the same fatal errror: https://go.dev/play/p/flEmSh1euqR (run locally) If the runtime.GC() statement is uncommented then the fatal error does not occur. The use of this

[go-nuts] array index not starting at 0

2024-01-29 Thread Leah Stapleton
go version go1.21.5 windows/amd64 There have been 9 garbage collections according to NumGC and also the PauseEnd array; However, the PauseNs array only shows two pause times, and they are incorrectly positioned in the array (the first time is logged at PauseNs[4] rather than PauseNs[0]) Can

[go-nuts] discrepancy between goal heap size and NextGC

2024-01-29 Thread Michael Mitchell
In the twelfth garbage collection of a short program I ran, GC trace reports the goal heap size as 735 MB (see below for gc11, gc12 and gc13 from GC trace) I also checked runtime Memstats (see attached image), and it says the nextGC target after 12 GCs have run is 838103616. Should goal Heap

[go-nuts] thoughts about https://go.dev/blog/loopvar-preview and how to change Go

2024-01-29 Thread Manlio Perillo
The proposal says: To ensure backwards compatibility with existing code, the new semantics will only apply in packages contained in modules that declare go 1.22 or later in their go.mod files. This per-module decision provides developer control of a gradual update to the new semantics

[go-nuts] Re: Scrapping with Colly - Pulling Elements one at a time

2024-01-28 Thread Tamás Gulácsi
var data MemberDetails detailCollector.OnHTML("div.block-container div.block-body:first-of-type", func(h *colly.HTMLElement) { selection := h.DOM key := selection.Find("dl > dt").Text() val := selection.Find("dl > dd").Text() switch key { case "Full name":

[go-nuts] Scrapping with Colly - Pulling Elements one at a time

2024-01-28 Thread Enrique
Hello, I am new to golang, and am working on a small web scrapper project, where i crawl through a website for a guild that i'm associated with. Ideally I would like to pull the data from each 'dl' (html below) and insert it into the MemberDetails Struct, however all attempts to parse the

Re: [go-nuts] Build kubernetes with gollvm

2024-01-28 Thread nanzi yang
Hello Yuan Ting: I am trying to build Kubernetes with gollvm, and I am glad you have made some progress. Did you finish compiling Kubernetes with gollvm and generating IR? If it is true, could you show me some practical steps so I can compile the Kubernetes to LLVM IR files? Looking forward to

Re: [go-nuts] Disable false positive go vet check in tests per line?

2024-01-28 Thread Steven Hartland
Thanks Kurtis, that's a good workaround :) On Sun, 28 Jan 2024 at 21:24, Kurtis Rader wrote: > What happens if you just alias the var? > > argsCopy := args > fmt.Printf("%v\n", argsCopy) > > > On Sun, Jan 28, 2024 at 12:13 PM Steven Hartland < > stevenmhartl...@gmail.com> wrote: > >> When

Re: [go-nuts] Disable false positive go vet check in tests per line?

2024-01-28 Thread Kurtis Rader
What happens if you just alias the var? argsCopy := args fmt.Printf("%v\n", argsCopy) On Sun, Jan 28, 2024 at 12:13 PM Steven Hartland wrote: > When running a test I'm getting: > missing ... in args forwarded to print-like function > > Usually this would be helpful as the pass in variadic

[go-nuts] Disable false positive go vet check in tests per line?

2024-01-28 Thread Steven Hartland
When running a test I'm getting: missing ... in args forwarded to print-like function Usually this would be helpful as the pass in variadic should generally be expanded with ... but in this case I specifically want the result of args passed as a slice. Is there a way to disable go vet checks for

<    3   4   5   6   7   8   9   10   11   12   >