Re: [go-nuts] time.ParseDuration does not accept scientific notation

2024-04-26 Thread Ian Lance Taylor
On Fri, Apr 26, 2024 at 3:39 PM Scott Pakin wrote: > > While parsing output from some third-party program, I discovered that > time.ParseDuration does not accept inputs expressed in scientific notation > even though strconv.ParseFloat does accept such inputs. Here’s an playground > example

Re: [go-nuts] generics question

2024-04-23 Thread Ian Lance Taylor
On Mon, Apr 22, 2024 at 11:01 PM Jochen Voss wrote: > > This works, see my code below. Followup question: is there a way to refer to > the new type without having to list both the element type and the pointer > type separately? Unfortunately there is not. At some point in the future the

Re: [go-nuts] generics question

2024-04-22 Thread Ian Lance Taylor
On Mon, Apr 22, 2024 at 2:25 PM Jochen Voss wrote: > > Using generics, can I somehow write a constraint which says that *T (instead > of T) implements a certain interface? The following code illustrated what > I'm trying to do: > > type A int > > func (a *A) Set(x int) { > *a = A(x) > } > >

Re: [go-nuts] error : undefined: app.NewWindow

2024-04-22 Thread Ian Lance Taylor
On Mon, Apr 22, 2024 at 10:54 AM AndyPeng wrote: > > Imported the "gioui.org/app" package,but got an error when compiling: > undefined: app.NewWindow. Please tell us exactly what you did and exactly what happened. Show us the code. Ian -- You received this message because you are subscribed

Re: [go-nuts] compiling go-1.22.2 and go-1.21.9 fail due to timeout during test of net/http package

2024-04-20 Thread Ian Lance Taylor
On Sat, Apr 20, 2024 at 7:34 PM Ron Hermsen wrote: > > compiling go-1.22.2 and go-1.21.9 fail due to timeout during test of net/http > package > > I tried a number of earlier releases but looks only the latest two fail. > (each build takes about 40min, so didn't try more options) > > > ok

Re: [go-nuts] TestCopyNWriteTo

2024-04-14 Thread Ian Lance Taylor
On Sun, Apr 14, 2024 at 8:05 PM Stephen wrote: > > https://github.com/golang/go/blob/c0a0ba254c48fc855f9501b0bd3b78e6847ca923/src/io/io_test.go#L167 > > I was walking through this code, and it didn't seem to hit [WriteTo] >

Re: [go-nuts] Is it possible to "extract" the generic [T] from a reflected type ?

2024-04-09 Thread Ian Lance Taylor
On Tue, Apr 9, 2024 at 9:41 AM Mihai Barbu wrote: > > I need to call some generic functions with types that are now known at > compile time. Is it possible to do this? > See the code below (vastly reduced). > > // fv is a function that returns an unknown type > func Do(fv reflect.Value){ > //

Re: [go-nuts] Failure in file seek

2024-04-08 Thread Ian Lance Taylor
On Mon, Apr 8, 2024, 3:33 PM Nikhilesh Susarla wrote: > I wanted to seek around a file by opening it using read-only, but then I > get this error called "Invalid argument" > > https://go-review.googlesource.com/c/go/+/14881 > > I read the above link and they say it is not supported to seek

Re: [go-nuts] user process instruction pointer symbol lookup

2024-04-02 Thread Ian Lance Taylor
On Tue, Apr 2, 2024 at 2:35 AM 'TheDiveO' via golang-nuts wrote: > > On Linux, given an arbitrary binary executable with symbol information in the > executable, how can I lookup an instruction pointer address to get the > corresponding symbol name? > > The binary (and its process) isn't a Go

Re: [go-nuts] Re: <-ctx.Done() panic - link injecting bot?

2024-04-01 Thread Ian Lance Taylor
On Sat, Mar 30, 2024 at 3:21 AM Steven Hartland wrote: > > Johans account looks like a bot designed to inject links, possibly malicious, > is there an admin who can investigate and take the appropriate action? Thanks for pointing that out. I think I've banned them. Ian -- You received this

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-25 Thread Ian Lance Taylor
On Sat, Mar 23, 2024 at 12:20 PM Jeffery Carr wrote: > > While doing that and looking at the code, there are lots of interesting and > good things in internal/ that can't be used. While I think I understand the > reasons for internal/, I wonder if the GO compiler might be more immune to >

Re: [go-nuts] New goroutine to immediately acquire the lock when Lock in starving mode?

2024-03-25 Thread Ian Lance Taylor
On Sat, Mar 23, 2024 at 11:58 AM Wen Wei wrote: > > Lock always calls runtime_SemacquireMutex(, queueLifo, 1) -> > semacquire1 when in starving mode. > > ```go > // src/runtime/sema.go > func semacquire1(addr *uint32, lifo bool, profile semaProfileFlags, > skipframes int, reason waitReason) { >

Re: [go-nuts] go vet not erroring waitgroup inc used after done

2024-03-25 Thread Ian Lance Taylor
On Mon, Mar 25, 2024 at 12:46 PM Nikhilesh Susarla wrote: > > Why isn't go vet complaining that wg.Add is happening after the usage. Where > as the document clearly says increment and then use it as the wg.Done may be > called an can run into negative/deadlock First, please send Go code as

Re: [go-nuts] Discussion on runtime/compiler meeting: Struct packing/reordering

2024-03-21 Thread Ian Lance Taylor
‪On Thu, Mar 21, 2024 at 4:47 PM ‫محمد بومنذر‬‎ wrote:‬ > > I have been following the Go Runtime and Compiler team meeting notes for a > while. In the recent notes, I noticed something that got my attention > regarding memory layout optimization for structures. >

Re: [go-nuts] io.Reader can return (n, err), both non-zero

2024-03-19 Thread Ian Lance Taylor
On Tue, Mar 19, 2024 at 6:40 PM Nigel Tao wrote: > > The ubiquitous io.Reader interface's Read method returns a (int, > error). Surprisingly (for programmers coming from other languages with > a built-in or idiomatic Result type), it's possible for both > return values to be non-zero. There's

Re: [go-nuts] Using new variable or updating existing variable in a loop

2024-03-19 Thread Ian Lance Taylor
On Tue, Mar 19, 2024 at 9:36 AM Mohamad Rostami wrote: > > I've seen in many places in go source code re-declaring a variable with the > same name. > e.g: > for i < j { >h := ... > } > Instead of > var h int > for i < j { >h = ... > } > > So I did a benchmark to check the differences. I

Re: [go-nuts] debug/gosym.PCToLine breaks on cgo enabled binaries

2024-03-13 Thread Ian Lance Taylor
On Wed, Mar 13, 2024 at 8:04 AM 'Grant Seltzer Richman' via golang-nuts wrote: > > I've been using the `Table.PCToLine` method to resolve program counters > (extracted via bpf) into functions with their file names and line numbers. > > It appears that this breaks when i'm testing it on a binary

Re: [go-nuts] How To Reduce Json Marshalling Time

2024-03-09 Thread Ian Lance Taylor
This thread has gotten heated. I think it's time to move on to different topics and give this discussion a rest. Thanks. Ian -- 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,

Re: [go-nuts] Why Go opt for using * in signature of function that returns a pointer instead of using &?

2024-03-05 Thread Ian Lance Taylor
On Tue, Mar 5, 2024, 8:33 PM Matheus Fassis Corocher < matheuscoroc...@gmail.com> wrote: > I was studying about pointers and struct in Golang and one thing that I > don't understand is why using * in return of signature of function instead > of & if the return of function is an address of

Re: [go-nuts] Enums, Go1 and proposals

2024-03-04 Thread Ian Lance Taylor
On Mon, Mar 4, 2024 at 11:32 AM Mike Schinkel wrote: > ... > 4. Relax the allowable values that can be assigned to a `const` to include > values that can be fully determined at compile time such as `const April = > [1]byte{4}` thus allowing `const` and > types of subtypes `struct`, `map`,

Re: [go-nuts] text template range over Rangefunc

2024-03-04 Thread Ian Lance Taylor
On Mon, Mar 4, 2024 at 11:47 AM Ajay Kidave wrote: > > The https://go.dev/wiki/RangefuncExperiment change will be a great addition > to the language. I wanted to know whether the text/html template std > libraries will allow range over rangefunc. Currently, the doc for > text/template says > >

Re: [go-nuts] Query Regarding ASAN C Call from Go Code

2024-03-04 Thread Ian Lance Taylor
4 г. в 00:43:09 UTC+3, Ian Lance Taylor: >> >> On Sun, Mar 3, 2024 at 1:25 PM Evgeny Chormonov wrote: >> > >> > I noticed that ASAN checker in the Go source code is defined using CGO >> > https://github.com/golang/go/blob/master/src/runtime/asan/asan.go >&g

Re: [go-nuts] Enums, Go1 and proposals

2024-03-04 Thread Ian Lance Taylor
On Mon, Mar 4, 2024 at 9:40 AM Jan Mercl <0xj...@gmail.com> wrote: > > The static type of an interface can be verified at compile time. The > value of a variable of an enum type (or a Pascal-like subrange) type, > cannot be verified at compile time in the general case. You would have > to add

Re: [go-nuts] Query Regarding ASAN C Call from Go Code

2024-03-03 Thread Ian Lance Taylor
On Sun, Mar 3, 2024 at 1:25 PM Evgeny Chormonov wrote: > > I noticed that ASAN checker in the Go source code is defined using CGO > https://github.com/golang/go/blob/master/src/runtime/asan/asan.go > But the C ASAN functions are called from the Go runtime using assembly code > instead of a

Re: [go-nuts] GO111MODULE=off go get deprecated?

2024-03-03 Thread Ian Lance Taylor
On Sun, Mar 3, 2024 at 1:25 PM Jeffery Carr wrote: > > Has this been deprecated or maybe it is broken in debian sid, but: > > bash$ GO111MODULE=off go get -v go.wit.com/apps/test > go: modules disabled by GO111MODULE=off; see 'go help modules' > basj$ go version > go version go1.22.0 linux/amd64

Re: [go-nuts] Plea for help diagnosing strange "signal: killed" issues in previously-working code

2024-03-02 Thread Ian Lance Taylor
On Sat, Mar 2, 2024 at 9:59 AM Russtopia wrote: > > Symptom: mysterious "signal: killed" occurrences with processes spawned from > Go via exec.Cmd.Start()/Wait() The first step is to tell us the exact and complete error that you see. "signal: killed" can have different causes, and the rest of

Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-01 Thread Ian Lance Taylor
l. > > This sounds very PHP - what goes around comes around. Good point, I am assuming that the OP is using the os/exec package to start up a new copy of the process. A simple fork without an exec can't work in Go, or in any multi-threaded program. Ian > > On Mar 1, 2024, at 8:

Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2024 at 5:57 PM Jeff Stein wrote: > > I'm struggling to understand if I'm able to do something. > > > In my very odd use case we are writing a websever that handles connections > via a forked process. > > I have a listener process that listens for TCP connections. > > So each

Re: [go-nuts] Do we need to drain a closed channel ?

2024-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2024 at 6:26 AM Shubha Acharya wrote: > > I have been working with buffered channels. I have stumbled upon a scenario > where buffered channel will be closed and the receivers of the channel > terminates before consuming all the elements in the buffer. So my question is > will

Re: [go-nuts] Re: How to have panic messages show in a PowerShell console

2024-03-01 Thread Ian Lance Taylor
On Fri, Mar 1, 2024 at 5:09 AM jake...@gmail.com wrote: > > FWIW, in a very simple test on Windows 10 in a powershell console, running a > go executable built with go1.19 prints the panic just like in a regular cmd > console. There have been a lot of changes related to Windows consoles since

Re: [go-nuts] go/version, "go2.00.1" < "go1.0.0"

2024-02-26 Thread Ian Lance Taylor
On Mon, Feb 26, 2024 at 8:26 PM leo zeng wrote: > > package main > > import "go/version" > > func main() { > var val int > val = version.Compare("go2.00.1", "go1.0.0") > print(val) // -1 > } Please write plain text as plain text. It's difficult to read against a dark background.

Re: [go-nuts] Probable bug in database/sql

2024-02-21 Thread Ian Lance Taylor
On Wed, Feb 21, 2024 at 4:27 PM Marco De Zio wrote: > > It seems to me that the second flag returned by Rows.nextLocked is wrongly > interpreted by Rows.Next as it sets rs.hitEOF = true when ok is false; also > Rows.nextLocked should set ok to true in some of the cases where right now >

Re: [go-nuts] Bad code contribution experience

2024-02-13 Thread Ian Lance Taylor
On Mon, Jan 29, 2024 at 7:29 PM mr@gmail.com wrote: > > 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

Re: [go-nuts] Opening network connections blocks system thread

2024-02-09 Thread Ian Lance Taylor
On Fri, Feb 9, 2024 at 11:57 AM Kurtis Rader wrote: > > The connect() syscall is normally blocking. It doesn't return until the > connection is established or an error occurs. It can be made non-blocking by > putting the file-descriptor into non-blocking mode before the connect() call. >

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

2024-02-08 Thread Ian Lance Taylor
On Wed, Feb 7, 2024 at 10:11 PM joseph.p...@gmail.com wrote: > > Variable substitution doesn't seem to work in an included template file. Is > that a known limitation? golang-nuts is for general discussion of Go, its tools, and its standard library. It's fine to ask about the Gin web framework

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

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

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] Re: About allowing conversion from bool to int

2023-10-20 Thread Ian Lance Taylor
On Fri, Oct 20, 2023 at 2:14 PM Victor Giordano wrote: > > My intention is to actually know any reason about not pushing forward that > proposal... because I need to understand why... *Is there any reason out > there? I don't know where to ask * > The first step is to read

Re: [go-nuts] What tool is used in Go Playground's import handling?

2023-10-20 Thread Ian Lance Taylor
On Thu, Oct 19, 2023 at 8:31 PM Pratik Tamgole wrote: > > When I use packages, any packages in general, how does the import("fmt") line > correct itself to include the used packages in the program? What tool is > implemented here, I want to put the same in my editor.

Re: [go-nuts] Can we not invoke methods on types referring to generics?

2023-10-19 Thread Ian Lance Taylor
On Thu, Oct 19, 2023 at 6:18 PM Nurahmadie Nurahmadie wrote: > > There are two ways to enable this, which are worth discussing further as of > why Go decided to behave this way. > > To use type alias as mentioned before `type MatrixF64 = Matrix[float64]`, > this is generally works but

Re: [go-nuts] Can we not invoke methods on types referring to generics?

2023-10-19 Thread Ian Lance Taylor
On Thu, Oct 19, 2023 at 5:14 PM Jason E. Aten wrote: > > Analogous to > > type IntSlice []int > > func (p IntSlice) Len() int { return len(p) } > func (p IntSlice) Less(i, j int) bool { return p[i].val < p[j].val } > func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } > > and then

Re: [go-nuts] bufio.Scanner - possible bug or doc err?

2023-10-13 Thread Ian Lance Taylor
6). I hope that will help guide people in the right direction. Ian > On Thursday, October 12, 2023 at 8:56:05 PM UTC+1 Ian Lance Taylor wrote: >> >> On Thu, Oct 12, 2023 at 10:21 AM 'Mark' via golang-nuts >> wrote: >> > >> > The docs for bufio.Scanner do

Re: [go-nuts] bufio.Scanner - possible bug or doc err?

2023-10-12 Thread Ian Lance Taylor
On Thu, Oct 12, 2023 at 10:21 AM 'Mark' via golang-nuts wrote: > > The docs for bufio.Scanner do say > "Programs that need more control over error handling or large tokens, or must > run sequential scans on a reader, should use bufio.Reader instead" > Perhaps it would be more helpful to mention

Re: [go-nuts] Question about runtime.Pinner

2023-10-12 Thread Ian Lance Taylor
On Thu, Oct 12, 2023 at 5:06 AM Pascal Costanza wrote: > > I have a question about runtime.Pinner: The documentation states that you can > only pin an object when it’s the result of calling new, taking the address of > a composite literal, or taking the address of a local variable. > > At the

Re: [go-nuts] The docs for secretbox seem very wrong

2023-10-09 Thread Ian Lance Taylor
On Mon, Oct 9, 2023, 1:59 PM Dean Schulze wrote: > That is mixing concerns (low cohesion), though. At the very least they > need to explain that in the docs. Otherwise that first parameter makes no > sense. > This is a common design pattern in Go. We shouldn't expect that every function that

Re: [go-nuts] cgo.go: multiple definition of `c_test_func'

2023-10-06 Thread Ian Lance Taylor
On Thu, Oct 5, 2023 at 3:13 PM sbezverk wrote: > > I struggle to understand why this simple cgo program does not get linked, I > would provide example in playground, but it does not seem to support cgo. > > ``` > package main > > > > // #include > > // > > // extern int go_test_func(int c1, int

Re: [go-nuts] Inlining of runtime/internal/atomic.Cas

2023-10-04 Thread Ian Lance Taylor
On Wed, Oct 4, 2023 at 5:36 AM Timur Celik wrote: > > Why is it that changes in the runtime package's atomic.Cas don't land in > my build? I suspect it has something to do with inlining of the > function, but even with `-gcflags=-l` the atomic.Cas original > implementation seems to get inlined.

Re: [go-nuts] Generic "nillable" constraint

2023-10-03 Thread Ian Lance Taylor
On Tue, Oct 3, 2023 at 5:57 PM Jon Watte wrote: > > > Can you give us an example? > > I already gave examples! They're in the thread! In reality, we have the > insides of a compiler where this would be helpful in more complex cases, and > we have the insides of a graphql and JSON web interface

Re: [go-nuts] Generic "nillable" constraint

2023-10-03 Thread Ian Lance Taylor
On Tue, Oct 3, 2023 at 12:06 PM Jon Watte wrote: > > I don't want to include int or struct{} in this case. I care specifically > about "can be compared to nil" > The only thing I can do with a type parameter that is only constrained as > "nil" is compare it to nil, or assign nil to it. > This

Re: [go-nuts] Re: Is it expected that signal.NotifyContext() changes the execution thread?

2023-10-02 Thread Ian Lance Taylor
On Sat, Sep 30, 2023 at 11:56 PM Kurtis Rader wrote: > > And having said that I just tested using runtime.LockOSThread() and it does > allow me to use the more obvious, natural, way to write the main() function. > Which still begs the question of why calling signal.NotifyContext() causes >

Re: [go-nuts] Generic "nillable" constraint

2023-10-02 Thread Ian Lance Taylor
There is a lot more on this topic at https://go.dev/issue/61372. We're not sure how best to handle it. Ian -- 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] How to understand assembly code related to defer

2023-09-27 Thread Ian Lance Taylor
On Tue, Sep 26, 2023 at 11:06 PM j2gg0s wrote: > > Related go code: > 22 //go:noinline > 23 func add(a, b int) int { > 24 defer func() { > 25 fmt.Println(3) > 26 }() > 27 return a + b > 28 } > > Build by: GOOS=linux

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread Ian Lance Taylor
On Tue, Sep 26, 2023 at 9:10 PM j2gg0s wrote: > > Already read it, I actually started here. > > What I can't understand is x64 rip-relative address. > > leaq132795(%rip), %rcx # 0x49b4e8 > > why 132795, and what is loaded into rcx It's a reference to another address in the program.

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread Ian Lance Taylor
On Tue, Sep 26, 2023 at 7:43 AM j2gg0s wrote: > > How to understand assmbly code ` 47ae26: 48 8d 0d bb 06 02 00 leaq > 132795(%rip), %rcx # 0x49b4e8 ` The best place to start is https://go.googlesource.com/proposal/+/refs/heads/master/design/34481-opencoded-defers.md Ian --

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-26 Thread Ian Lance Taylor
On Tue, Sep 26, 2023 at 3:32 AM sbezverk wrote: > > Thank you for your reply, I was under impression that prototype definitions > come from C header files, and since the compilation phase completes with > success, cgo finds all necessary function definitions. My problem is at the > linking

Re: [go-nuts] cgo and dynamic linking of shared labraries

2023-09-25 Thread Ian Lance Taylor
On Sat, Sep 23, 2023 at 6:38 AM sbezverk wrote: > > Since I could not find the answer in the cgo documentation, I would really > appreciate if somebody could help me to understand why when I build cgo code > with calls to the shared library, the linker tries to find the shared library > even

Re: [go-nuts] Golang+CGO using ucontext crash(on purpose) with SIGSEGV or SIGTRAP while using different stacks

2023-09-25 Thread Ian Lance Taylor
On Sat, Sep 23, 2023 at 10:32 PM zk Z wrote: > > I'm currently writing a Golang + CGO program, and will use posix ucontext in > CGO. Since all my core logic will be in the bind function of ucontext, we > should catch up all the bad code. And I test it by accessing to the null > pointer, which

Re: [go-nuts] panic: nil dereference in autogenerated hash function

2023-09-22 Thread Ian Lance Taylor
On Fri, Sep 22, 2023 at 9:15 AM Shivaram Lingamneni wrote: > > I'm having difficulty understanding how this code could produce a nil > dereference, unless some runtime assumptions are being violated (maybe the > string pointer and length are out of sync due to a data race)? I agree: this looks

Re: [go-nuts] NTFS deduplicated files changed from regular to symlink in go 1.21

2023-09-21 Thread Ian Lance Taylor
[ + Quin Muntal ] On Thu, Sep 21, 2023 at 10:34 AM Simon Frei wrote: > > Hi, > > We got a report in syncthing that some files fail to sync on an ntfs > filesystem with deduplication enabled after upgrading the app: > https://github.com/syncthing/syncthing/issues/9120 > The only change relevant

Re: [go-nuts] Go 1.21.0 panics on macos ventura 13.5.2

2023-09-21 Thread Ian Lance Taylor
On Thu, Sep 21, 2023 at 2:16 PM Pierre Laplante wrote: > > Running make planic with: > > fatal error: forcegc: phase error Note for mailing list: this was reported as https://go.dev/issue/63151. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] semantics of panic stack traces

2023-09-18 Thread Ian Lance Taylor
On Sun, Sep 17, 2023 at 2:44 PM 'Dan Kortschak' via golang-nuts wrote: > > I'm trying to get my head around a panic stack trace from a user > report[1]. > > The parameter value make very little sense to me based on what they > should be from following the program logic. For example the {0x0?,

Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Ian Lance Taylor
On Wed, Sep 13, 2023 at 12:27 PM 'John Souvestre' via golang-nuts wrote: > > What is TIL? https://knowyourmeme.com/memes/today-i-learned-til Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] How ignore a subdirectory

2023-09-13 Thread Ian Lance Taylor
On Tue, Sep 12, 2023 at 8:47 PM 'John Souvestre' via golang-nuts wrote: > > I’m trying to run gofmt on all of the .go files in a directory, but not any > subdirectories. I have tried using “.” for the target. It does get all of > the .go in the current directory, but it also does all the .go

Re: [go-nuts] x/mobile: avoid to catch sigabort signal

2023-09-08 Thread Ian Lance Taylor
On Thu, Sep 7, 2023 at 11:41 PM Danilo bestbug wrote: > > Some weeks ago I've opened a possible bug on github and the only response I > received is a reference to > "This looks like the program (the Go runtime, or not) intentionally crashing > when it is already in a bad condition, like

Re: [go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-28 Thread Ian Lance Taylor
s? Or generally, is > copying their "untouched" zero-values always safe? Yes, in general it's safe to copy the untouched zero value of these types. Ian > On Sunday, August 27, 2023 at 7:05:15 PM UTC+2 Ian Lance Taylor wrote: >> >> On Sun, Aug 27, 2023 at 7:54 AM Antonio

Re: [go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-27 Thread Ian Lance Taylor
On Sun, Aug 27, 2023 at 7:54 AM Antonio Caceres Cabrera wrote: > > Go vet complains about this minimal example code > > type Foo struct { > val atomic.Uint64 > } > > func main() { > var foos = make([]Foo, 0) > var bar Foo > bar.val.Store(5) > foos = append(foos,

Re: [go-nuts] Reason for "goto jumps over declaration" being disallowed

2023-08-26 Thread Ian Lance Taylor
On Sat, Aug 26, 2023 at 2:11 PM Mike Schinkel wrote: > > Question about disallowing `goto ` jumping over a variable declaration? > > > And please, before bikeshedding opinions about the use of `goto` pro or con — > note that the Go standard library uses `goto` in some places — this question >

Re: [go-nuts] Would it be possible to make this work in the future?

2023-08-25 Thread Ian Lance Taylor
r clarifying. I do see how the compiled version will need to be > repetitive, although as you mentioned this piece of code is not a common case. > في Friday, August 25, 2023 في تمام الساعة 11:43:05 PM UTC+3، كتب Ian Lance > Taylor رسالة نصها: >> >> ‪On Fri, Aug 25, 2023 at

Re: [go-nuts] Would it be possible to make this work in the future?

2023-08-25 Thread Ian Lance Taylor
‪On Fri, Aug 25, 2023 at 7:43 AM ‫محمد بومنذر‬‎ wrote:‬ > > I'm writing a parser based on Go's `encoding/xml`, I tried to use the > following pattern but it was deemed invalid: > > ``` > To me, it'd make sense if it was allowed since both types are structs and > both of them share the field

Re: [go-nuts] Replicating C unions with unsafe, arrays, and some constant arithmetic

2023-08-24 Thread Ian Lance Taylor
Note that is not permitted by the rules of the unsafe package, and that in particular it will break the garbage collector if any of the types stored in the union contain pointer fields. Ian On Thu, Aug 24, 2023, 7:59 PM aind...@gmail.com wrote: > I found this trick recently to replicate a C

Re: [go-nuts] Crash using gccheckmark=1, possible GC bug?

2023-08-18 Thread Ian Lance Taylor
On Fri, Aug 18, 2023 at 8:12 AM Tibor Halter wrote: > > Hi Elias, thanks for chiming in! > > > The Go garbage collector is precise in that it only considers pointers when > > determining memory that can be freed. > > Agreed, but it is not as precise on _what_ is a pointer. Specifically, which >

Re: [go-nuts] Crash using gccheckmark=1, possible GC bug?

2023-08-17 Thread Ian Lance Taylor
On Thu, Aug 17, 2023 at 5:41 PM Tibor Halter wrote: > > I get this crash when using the GODEBUG option gccheckmark=1: > > runtime: marking free object 0xc0016c5668 found at *(0xc0046ca8e0+0x8) > base=0xc0046ca8e0 s.base()=0xc0046ca000 s.limit=0xc0046cc000 s.spanclass=8 > s.elemsize=32

Re: [go-nuts] Why is reflect.Type defined as an interface, but reflect.Value is defined as a struct?

2023-08-17 Thread Ian Lance Taylor
On Thu, Aug 17, 2023 at 10:02 AM Hu Jian wrote: > > I'm curious why reflect.Type is defined as an interface, but reflect.Value is > defined as a struct? I don't see any other implementation of the reflect.Type > interface. reflect.Value is an ordinary struct. The reflect.Type interface is

Re: [go-nuts] why the go install package download from official website of go1.21 is less than go1.20?

2023-08-16 Thread Ian Lance Taylor
I think that for 1.21 the biggest difference is that we aren't including debug info with the binaries in $GOROOT/pkg/tool/$GOOS_$GOARCH. That change was made in https://go.dev/cl/475378. Ian Ian On Wed, Aug 16, 2023 at 12:46 PM Jeremy Cattone wrote: > > Looks like on-going work, finally

Re: [go-nuts] cgo pam module signal handling

2023-08-15 Thread Ian Lance Taylor
dler for all threads in the process. When in step 5 a SIGCHLD signal is received, it will go to the signal handler installed in step 4, not the signal handler installed in step 1. Yes, an strace dump would help clarify this. Thanks. Ian > On Monday, August 14, 2023 at 12:17:34 PM UTC-7 Ian L

Re: [go-nuts] epoll: why write 1 byte to the pipe in netpollBreak() and read up to 16 bytes in netpoll()?

2023-08-14 Thread Ian Lance Taylor
tpollWakeSig", does it still hold > true? Thanks. Good point, I think you're right. With netpollWakeSig we shouldn't expect to see more than a single byte written to the pipe. Doesn't hurt to try to read more bytes, though. Ian > On Tuesday, July 11, 2023 at 9:00:36 AM UTC+8 Ian La

Re: [go-nuts] cgo pam module signal handling

2023-08-14 Thread Ian Lance Taylor
l handler. Which thread a signal is delivered to does not affect which signal handler gets run. Ian > On Friday, August 11, 2023 at 10:05:48 PM UTC-7 Ian Lance Taylor wrote: >> >> On Fri, Aug 11, 2023 at 11:51 AM Chandrasekhar R wrote: >> > >> > I am plan

Re: [go-nuts] How to Create Dynamically Linked Go Programs Redux

2023-08-12 Thread Ian Lance Taylor
> On Friday, August 11, 2023 at 10:00:12 PM UTC-7 Ian Lance Taylor wrote: >> >> On Fri, Aug 11, 2023 at 6:15 PM jlfo...@berkeley.edu >> wrote: >> > >> > Now that Go 1.21 has been released, I've returned to trying to figure out >> > how to >

Re: [go-nuts] cgo pam module signal handling

2023-08-11 Thread Ian Lance Taylor
On Fri, Aug 11, 2023 at 11:51 AM Chandrasekhar R wrote: > > I am planning on using a pam module written in Go (specifically > https://github.com/uber/pam-ussh) . When I run a script which calls sudo > continuously with an echo command, I am noticing zombie/defunct processes > starting to pop

Re: [go-nuts] How to Create Dynamically Linked Go Programs Redux

2023-08-11 Thread Ian Lance Taylor
On Fri, Aug 11, 2023 at 6:15 PM jlfo...@berkeley.edu wrote: > > Now that Go 1.21 has been released, I've returned to trying to figure out how > to > dynamically link a Go program. Back in January I posted the results of my > first attempt > with an earlier version of Go, which was: > > 1)

Re: [go-nuts] What does "shallow clone" mean?

2023-08-11 Thread Ian Lance Taylor
On Fri, Aug 11, 2023, 7:28 AM shinya sakae wrote: > maps package was released with Go 1.21. > Clone() comment says "This is a shallow clone". > I often hear the term `shallow copy', but I don't know what `shallow > clone` means. > What is the state of a `shallow cloned` map? > Do you mean that

Re: [go-nuts] What happened to sep in errorrs.join

2023-08-08 Thread Ian Lance Taylor
t; library handler and I do not want new lines in the message or keys. > > Would the go team would be open to providing knobs to control how the handler > does formatting? I assumed if I tried opening a proposal like that I’d be > told to write a custom handler. :) > > On Mon, Aug

Re: [go-nuts] What happened to sep in errorrs.join

2023-08-07 Thread Ian Lance Taylor
On Mon, Aug 7, 2023 at 4:32 AM jal...@gmail.com wrote: > > In the errors.join proposal, the proposed api had the user specify how they > wanted the errors to be formatted together. But the actual implementation > omitted and only used new line. > > This is quite unfortunate if you are using

Re: [go-nuts] Why is type inference still so rudimentary?

2023-08-04 Thread Ian Lance Taylor
On Fri, Aug 4, 2023 at 8:08 AM Nate Finch wrote: > > If I have a struct > > type User struct { > Name string > ID int > } > > type Group struct { > Leader User > } > > Why is it that the go tool can't infer what type I'm constructing for the > Leader field here? > > g := Group{ >

Re: [go-nuts] go11tag

2023-07-28 Thread Ian Lance Taylor
On Fri, Jul 28, 2023 at 9:55 AM John Pritchard wrote: > > Debugging "go build" with dlv, which hungup at > > go/src/cmd/go/main.go:92:var _ = go11tag > > Looking around a bit, found no particular rationale for the existence of > "go11tag". It's a small test. See the comment on the

Re: [go-nuts] error handling thoughts

2023-07-27 Thread Ian Lance Taylor
On Thu, Jul 27, 2023 at 8:04 AM Steve Roth wrote: > > In those cases, what I'd like to write is > > if result, err := fn(); err != nil { > > // handle error and bail out > > } else { > > // act on result > } > > > Unfortunately, the compiler gives a warning on that. As others have

Re: [go-nuts] Re: Possible Go Compiler or Runtime bug?

2023-07-27 Thread Ian Lance Taylor
On Thu, Jul 27, 2023 at 3:17 PM 'Michael Knyszek' via golang-nuts wrote: > > The number 32 for the capacity comes from this constant, and the returned > byte slice in that case is likely coming from a compiler-inserted call to > stringtoslicebyte. An empty string is correctly replaced by a

Re: [go-nuts] go package dating back to 2009

2023-07-25 Thread Ian Lance Taylor
On Tue, Jul 25, 2023 at 3:29 PM Bravo Moua wrote: > > How bout prior to the public release in nov 2009? Well here's the story, Im > looking for the creator of Bitcoin, I was a part of the creation of Bitcoin > from the beginning. We ve coded some codes in Golang in Jan 2009. Just asking >

Re: [go-nuts] go package dating back to 2009

2023-07-24 Thread Ian Lance Taylor
On Mon, Jul 24, 2023 at 3:08 PM Bravo Moua wrote: > > How can one search for packages dating back to Jan 2009 Well, Go was only publicly released in November, 2009, so there are no public Go packages as old as January, 2009. I assume you know that you can search for Go packages today at

Re: [go-nuts] [net.mail] ReadMessage returns nil, io.EOF when email w/o body.

2023-07-18 Thread Ian Lance Taylor
On Tue, Jul 18, 2023 at 4:36 PM Karan Gupta wrote: > > RFC 5322 (https://www.rfc-editor.org/rfc/rfc5322#section-3.5) allows for > messages without bodies. > ` A message consists of header fields, optionally followed by a message body ` > > However, the net/mail . ReadMessage returns an error

Re: [go-nuts] epoll: why write 1 byte to the pipe in netpollBreak() and read up to 16 bytes in netpoll()?

2023-07-10 Thread Ian Lance Taylor
On Mon, Jul 10, 2023 at 6:10 AM shaouai wrote: > > In the implementation of the Go netpoller, `netpollBreak()` attempts to write > 1 byte to `netpollBreakWr`, whereas `netpoll()` reads up to 16 bytes from > `netpollBreakRd`, why 16 bytes rather than 1 byte? > > write up to 1 byte: >

Re: [go-nuts] Interface() method of reflect.Value sometimes allocates, sometimes not

2023-06-26 Thread Ian Lance Taylor
On Mon, Jun 26, 2023 at 8:28 AM christoph...@gmail.com wrote: > > I'm implementing a value encoder similar to gob. While bench-marking my code > against gob, I noticed some unexpected memory allocations with a particular > type of data. > > See this minimal code example in the go playground >

Re: [go-nuts] Static binary with c lib dep. Is it possible?

2023-06-21 Thread Ian Lance Taylor
On Wed, Jun 21, 2023 at 12:27 PM Marcondes Viana de Oliveira Junior wrote: > > Hi all, I’m trying to create a static binary (no external deps) for linux, on > linux, using libwebp as dep. > > webp.go > === > ... > /* > #cgo pkg-config: libwebp > #include > #include > ... > */ > > import

Re: [go-nuts] Locking (`__GI___pthread_mutex_unlock`) takes most of the execution time when using cgo with large number of CPUs

2023-06-20 Thread Ian Lance Taylor
On Tue, Jun 20, 2023 at 3:36 PM robert engels wrote: > > Since this is an initialization guard - can’t it simply be double checked > with an atomic flag? That would be a good first thing to try. Ian > > On Jun 20, 2023, at 9:04 AM, Ian Lance Taylor wrote: > > > >

Re: [go-nuts] Locking (`__GI___pthread_mutex_unlock`) takes most of the execution time when using cgo with large number of CPUs

2023-06-20 Thread Ian Lance Taylor
On Tue, Jun 20, 2023 at 5:32 AM Bảo Phan Quốc wrote: > > I'm using cgo to call a C function from Go. Inside the C function there is a > callback to a Go function. In other way, I'm calling Go -> C -> Go. > > After running pprof, I noticed that the __GI___pthread_mutex_unlock took half > of the

Re: [go-nuts] (BUG REPORT) Wrong CGO conditions in golang/glog

2023-06-19 Thread Ian Lance Taylor
On Mon, Jun 19, 2023 at 11:46 AM '方佳文' via golang-nuts wrote: > > Hi, maintainers of https://github.com/golang/glog: > > There is a bug in golang/glog that the CGO condition is wrong. > > https://github.com/golang/glog/blob/03ad3c2a3f1c767129f0b355507de7ae615f53b8/glog_file_linux.go#L17 > >

Re: [go-nuts] can't read data from the tun device

2023-06-16 Thread Ian Lance Taylor
On Thu, Jun 15, 2023 at 10:41 PM akalio ja wrote: > > GOVERSION="go1.20.3" Thanks. You didn't say what the exact problem was, but I would guess that you are running into the problem described at https://go.dev/issue/59545. That problem should be fixed in the upcoming 1.21 release. Ian >

Re: [go-nuts] can't read data from the tun device

2023-06-15 Thread Ian Lance Taylor
What version of Go are you using? Ian On Thu, Jun 15, 2023, 5:32 AM akalio ja wrote: > func openTun(ch chan int, timer *time.Timer) { > > fd, err := unix.Open("/dev/net/tun", unix.O_RDWR|unix.O_NONBLOCK, 0) > if err != nil { > panic(err) > } > defer unix.Close(fd) > >

Re: [go-nuts] [generics] instantiation of structs within generic functions

2023-06-08 Thread Ian Lance Taylor
On Thu, Jun 8, 2023 at 8:59 PM Jim Minter wrote: > > I'm rather confused by instantiation of structs in generic functions. I > happen to be using go protobufs. Unlike with `json.Unmarshal`, > `proto.Unmarshal` expects to receive a fully pre-instantiated struct to > unmarshal into. The

  1   2   3   4   5   6   7   8   9   10   >