[go-nuts] [x/term] Adding history save/restore/clear/etc and some small issues

2024-06-06 Thread Dragos Vingarzan
Hey folks, I recently embedded the golang.go/x/term into my application and I love the simplicity and effectiveness of having such a terminal. The history part of it is also great to have, but even better if one could save/restore the history over application restarts. I did some changes and

[go-nuts] Re: Guidance on techniques that can help me write a comprehensive test for my go library.

2024-06-06 Thread Jeremy French
This: > "I want to be able to mock every function in my library." is a bit confusing. Normally, you want to mock the functions that your library calls, not your own library functions. Other than that, this seems pretty doable.. Can you give some more clarification as to what aspect is giving

[go-nuts] Re: Guidance on techniques that can help me write a comprehensive test for my go library.

2024-06-06 Thread Marcello H
Normally, the way to use the functions/methods of the external library is by having an interface with all the function definitions. Then you can generate a mock that offers the same functionality. With such a mock, you can give all kinds of results back to the caller. Do you have your project

[go-nuts] Guidance on techniques that can help me write a comprehensive test for my go library.

2024-06-05 Thread Ai Readone
Hello Everyone, I am currently writing a go library that Integrates various Google cloud services. The aim of the library is to eliminate duplicate implementations across various services of the same software. I am having challenges on how to write a comprehensive test for my library, the main

[go-nuts] [security] Go 1.22.4 and Go 1.21.11 are released

2024-06-04 Thread announce
Hello gophers, We have just released Go versions 1.22.4 and 1.21.11, minor point releases. These minor releases include 2 security fixes following the security policy : - archive/zip: mishandling of corrupt central directory record The archive/zip

Re: [go-nuts] Does I/O in Goroutine blocks the underlying thread?

2024-06-03 Thread Ian Lance Taylor
On Mon, Jun 3, 2024 at 1:09 AM Haoyang Fan wrote: > > Let's say if I'm writing a program in Golang that is similar to the "top" > command, which rapidly reads the files under /proc directory (e.g. every 1 > second) and I'm launching goroutines to read different parts of that > directory. Since

Re: [go-nuts] Changing Epoll mode for Golang runtime

2024-06-03 Thread Ian Lance Taylor
On Mon, Jun 3, 2024 at 12:42 PM armin afsharian wrote: > > For my research project, I'm trying to change the Go runtime to use > "Epolloneshot" instead of the default "Edge-Triggered" mode. Based on what > I've gathered from the code, I've changed two functions in >

[go-nuts] Re: HTTP method before the endpoint

2024-06-03 Thread rogerjd
If it helps someone else, : The problem was it was using go version 1.20 Needed to change go.mod to use go 1.22.3 On Monday, June 3, 2024 at 1:20:20 PM UTC-4 rogerjd wrote: > Your code works both in the playground and on my local machine. > I need to figure what I did wrong originally. > Thank

[go-nuts] Changing Epoll mode for Golang runtime

2024-06-03 Thread armin afsharian
Hi there, For my research project, I'm trying to change the Go runtime to use "Epolloneshot" instead of the default "Edge-Triggered" mode. Based on what I've gathered from the code, I've changed two functions in src/runtime/netpoll_epoll.go. First, I updated the netpollopen function to use

[go-nuts] Re: HTTP method before the endpoint

2024-06-03 Thread rogerjd
Your code works both in the playground and on my local machine. I need to figure what I did wrong originally. Thank you for helping, Roger On Monday, June 3, 2024 at 3:26:22 AM UTC-4 p...@morth.org wrote: > Hi, > > It works on the playground at least, https://go.dev/play/p/YZbgmezjSIV > Are you

Re: [go-nuts] Does I/O in Goroutine blocks the underlying thread?

2024-06-03 Thread Haoyang Fan
Let's say if I'm writing a program in Golang that is similar to the "top" command, which rapidly reads the files under /proc directory (e.g. every 1 second) and I'm launching goroutines to read different parts of that directory. Since /proc is a virtual filesystem not actually stored on the

[go-nuts] Re: HTTP method before the endpoint

2024-06-03 Thread p...@morth.org
Hi, It works on the playground at least, https://go.dev/play/p/YZbgmezjSIV Are you sure your server is listening on port 80? That's fairly uncommon for service code and usually requires extra permissions. If it's listening on another port, you'll have to specify that in the browser as well (see

[go-nuts] HTTP method before the endpoint

2024-06-02 Thread rogerjd
Routing Enhancements for Go 1.22 I have this in the init func for main http.HandleFunc("GET /posts", handlePost2) Yet, in the browser, when http://127.0.0.1/posts is entered, it returns 404 page not found. Am I doing something wrong? Maybe the problem lies elsewhere? Thank you, Roger func

Re: [go-nuts] Does I/O in Goroutine blocks the underlying thread?

2024-05-31 Thread Ian Lance Taylor
On Fri, May 31, 2024 at 12:09 PM Haoyang Fan wrote: > > I was always under the impression that Go solely uses async I/O under the > hood so that when invoking a seemingly blocking call like os.File.Read the > underlying thread won't be blocked. Go scheduler will save the context of > current

Re: [go-nuts] Does I/O in Goroutine blocks the underlying thread?

2024-05-31 Thread robert engels
It does. I think the wording is wrong - the Go routine blocks - but the carrier thread (that was running the Go routine) runs another Go routine (if needed and ready to run). > On May 31, 2024, at 2:54 AM, Haoyang Fan wrote: > > Hi everyone, > > I was always under the impression that Go

[go-nuts] Does I/O in Goroutine blocks the underlying thread?

2024-05-31 Thread Haoyang Fan
Hi everyone, I was always under the impression that Go solely uses async I/O under the hood so that when invoking a seemingly blocking call like os.File.Read the underlying thread won't be blocked. Go scheduler will save the context of current goroutine and schedule other goroutines to run on

Re: [go-nuts] multiple rangefunc iterators: restart?

2024-05-31 Thread Rory Campbell-Lange
On 31/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > On 23/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > > I've been playing with with rangefunc experiment... > > ...reference to python nested yield example... > > > for p in people: > > for c in p.cars:

Re: [go-nuts] multiple rangefunc iterators: restart?

2024-05-31 Thread Rory Campbell-Lange
On 23/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > I've been playing with with rangefunc experiment... ...reference to python nested yield example... > for p in people: > for c in p.cars: > for t in c.tickets: > print("person {} in car {}

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-31 Thread Benoît Marguerie
Just for information, I've written an issue on go compiler to follow this evolution: https://github.com/golang/go/issues/67744 Le vendredi 31 mai 2024 à 10:15:02 UTC+2, Benoît Marguerie a écrit : > Good question ! > > But delve mainly extracts its symbols from Dwarf info. And when I try to >

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-31 Thread Benoît Marguerie
Good question ! But delve mainly extracts its symbols from Dwarf info. And when I try to get them with your code, I obtain this: *~/tmp$ objdump -W main | grep -i constV<2547> DW_AT_name: main.constValueInt* We can see that the compiler puts some debug tags for const int values

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-30 Thread Kurtis Rader
Your question should have included more information such as the Go version. Nonetheless, I don't see how Delve is able to resolve "myValueInt" in your example. I modified your code to include non-const versions of the symbols: package main import "fmt" const constValueStr = "abc" const

[go-nuts] [security] Go 1.22.4 and Go 1.21.11 pre-announcement

2024-05-30 Thread announce
Hello gophers, We plan to issue Go 1.22.4 and Go 1.21.11 during US business hours on Tuesday, June 4. These minor releases include PRIVATE security fixes to the standard library, covering the following CVE: - CVE-2024-24790 Following our security policy, this is the pre-announcement of

Re: [go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-30 Thread 'Alex Kristiansen' via golang-nuts
Thanks for the response Michael. > It looks like a Windows minidump (unsurprisingly) can't follow the relation. A regular goroutine stack trace dump that gets emitted on a forced exit or crash is able to show both sides of the system stack switch with a little bit of configuration. Yeah, that

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-30 Thread Benoît Marguerie
or, in a easier way, a full "copy/paste" example of code: package main import "fmt" const myValueStr = "try" const myValueInt = 12 func main() { fmt.Println("Instruction only to put a breakpoint") } Le jeudi 30 mai 2024 à 10:53:50 UTC+2, Benoît Marguerie a écrit : > Of course! > The code

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-30 Thread Benoît Marguerie
Of course! The code can be really simple like this: *const myValueStr = "try"const myValueInt = 12* *func DoSomething() { fmt.Println("Instruction only to put a breakpoint")}* and the result with delve: *(dlv) print %v myValueInt12(dlv) print %v myValueStrCommand failed: could

Re: [go-nuts] Symbol of const string are not exported by compiler

2024-05-30 Thread Jan Mercl
On Thu, May 30, 2024 at 10:34 AM Benoît Marguerie wrote: > I discovered a "strange" behavior doing a simple operation. > I defined 2 const : one integer and one string. With delve (or other > debugger), I'm able to consult the const integer value but not the const > string value. Delve team

[go-nuts] Symbol of const string are not exported by compiler

2024-05-30 Thread Benoît Marguerie
Hello All, I discovered a "strange" behavior doing a simple operation. I defined 2 const : one integer and one string. With delve (or other debugger), I'm able to consult the const integer value but not the const string value. Delve team explained me that the go compiler doesn't export symbol

Re: [go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-29 Thread 'Michael Knyszek' via golang-nuts
The example goroutine in the original post is parked waiting for some other goroutine to finish up the GC cycle. Somewhere, a goroutine is getting stuck trying to finish it up, which could possibly be a deadlock. (I am especially suspicious of a deadlock bug because most threads are stopped

Re: [go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-29 Thread robert engels
I am pretty sure runtime is supposed to crash the process if it slows the allocators “too much” (I believe there are some config settings to control this). If you have enough Go routines it may look like they are hung - you need to track specific routines by their ID. The stack certainly looks

Re: [go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-29 Thread 'Alex Kristiansen' via golang-nuts
That's an interesting idea, I probably wouldn't have thought of that on my own. Is that expected behavior for memory pressure on Windows+golang? I don't have much windows experience, so my assumption would be that the Windows equivalent of the OOMKiller would kick in and just kill the

Re: [go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-28 Thread robert engels
Feels like a memory leak to me. I would look for growing heap size in the gc logs. I am guessing that the system is not completely hung - but rather the runtime is having a hard time obtaining more memory, so it is slowing the allocators to a rate that makes them appear hung. It may be that

[go-nuts] Memory operations hung in semacquire state, GC routine parked while holding semaphore?

2024-05-28 Thread 'Alex Kristiansen' via golang-nuts
This is an odd one. For reference, this is a customer machine, Windows server 2016, compiled with go1.20.11. The application just hangs after a number of days; windows minidump reveals that most threads are doing this: Goroutine 462 - User: unicode/utf16/utf16.go:106 unicode/utf16.Decode

[go-nuts] Re: Protobuf build error with gogo - has inconsistent names structpb

2024-05-28 Thread Ian Vernon (ianvernon92)
Did you ever figure this out? I am hitting the same issue, and it's quite frustrating :( On Monday, July 25, 2022 at 2:08:18 AM UTC-7 santhoshth...@gmail.com wrote: > Hi Everyone > > I am importing the proto of other project into my proto file and run > protoc command. > I got this below

Re: [go-nuts] Significance of using a buffered channel of capacity 1.

2024-05-27 Thread Deepak Pathak
IMHO, this is so that the sender of ths signal to your channel doesn't gets blocked. A helpful blog to understand it: https://www.rudderstack.com/blog/implementing-graceful-shutdown-in-go/ Hope it helps! On Thursday 30 July 2015 at 02:42:50 UTC+5:30 Bakul Shah wrote: > On Wed, 29 Jul 2015

[go-nuts] Re: Upgrading to last version of dependency without upgrading toolchain?

2024-05-25 Thread 'TheDiveO' via golang-nuts
For the archeologists, underlying issue has been acknowledged https://github.com/golang/go/issues/67574; sadly, this forum kept schtumm. On Monday, May 6, 2024 at 1:46:17 PM UTC+2 TheDiveO wrote: > As I cannot edit the title anymore: it's about upgrading to the last > version that can be used

Re: [go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Harris, Andrew
May 24, 2024 7:18:51 AM To: Jochen Voss Cc: golang-nuts Subject: Re: [go-nuts] mutex in slog/handler.go? Git blame may be helpful, and specifically commit 847d40d6998. It looks like code drifted from the comment. -eli On May 24, 2024, at 9:25 AM, Jochen Voss wrote: Hello, In the Go st

Re: [go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Eli Lindsey
Git blame may be helpful, and specifically commit 847d40d6998. It looks like code drifted from the comment.-eli On May 24, 2024, at 9:25 AM, Jochen Voss wrote:Hello,In the Go standard library, in the file log/slog/handler.go, I found the following code:func (h *commonHandler) clone()

[go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Jochen Voss
Hello, In the Go standard library, in the file log/slog/handler.go, I found the following code: func (h *commonHandler) clone() *commonHandler { // We can't use assignment because we can't copy the mutex. return { json: h.json, opts: h.opts, preformattedAttrs:

[go-nuts] multiple rangefunc iterators: restart?

2024-05-23 Thread Rory Campbell-Lange
I've been playing with with rangefunc experiment, with help from https://go.dev/wiki/RangefuncExperiment and the possible idioms that might come out of it (https://blog.perfects.engineering/go_range_over_funcs is a good read). One somewhat eccentric use of nested iterators I built in the past

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-23 Thread 'Brian Candler' via golang-nuts
"try building at the command line" That's your clue. You'll most likely get a meaningful error message on stderr, which your IDE is hiding. On Thursday 23 May 2024 at 13:47:10 UTC+1 Pavan Kumar A R wrote: > Hello , > > I am try to call the c program in the golang , but i am getting the issue

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-23 Thread Pavan Kumar A R
Hello , I am try to call the c program in the golang , but i am getting the issue . please see the error message : package main go list failed to return CompiledGoFiles. This may indicate failure to perform cgo processing; try building at the command line. See

Re: [go-nuts] vet: Respect PATH

2024-05-22 Thread 'wagner riiffel' via golang-nuts
On 5/21/2024 12:48 PM, andrew.p...@gmail.com wrote: Please simplify both of these, so that the user can simply run: go vet -vettool=shadow Or: shadow ./... > In other words, the user should be able to invoke gofmt on a large Go > project with: > > gofmt ./... > > Same request for goimports.

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-22 Thread peterGo
cgo command https://pkg.go.dev/cmd/cgo Cgo enables the creation of Go packages that call C code. On Wednesday, May 22, 2024 at 4:41:13 PM UTC-4 Carla Pfaff wrote: > Yes, you can call C functions from Go, it's called Cgo: > https://go.dev/blog/cgo > > On Wednesday 22 May 2024 at

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-22 Thread 'Carla Pfaff' via golang-nuts
Yes, you can call C functions from Go, it's called Cgo: https://go.dev/blog/cgo On Wednesday 22 May 2024 at 18:04:19 UTC+2 Pavan Kumar A R wrote: > >> Okay, it's possible to call the C program to Golang. Because I also have >> the C platform dlls and the C platform dlls we using in the cross

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread Kenneth Miller
I changed the terminal and then it worked. On Wednesday, May 22, 2024 at 10:39:05 AM UTC-6 Brian Candler wrote: > * Start in an empty directory > * Run "go mod init example" > * Create your main.go with that import statement in it > * Run: > > go mod tidy > go run . > > On Wednesday 22 May 2024

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread 'Brian Candler' via golang-nuts
* Start in an empty directory * Run "go mod init example" * Create your main.go with that import statement in it * Run: go mod tidy go run . On Wednesday 22 May 2024 at 16:26:54 UTC+1 Kenneth Miller wrote: > I tried that, same error > > On Wednesday, May 22, 2024 at 9:12:58 AM UTC-6 Brian

Re: [go-nuts] Re: Call the .net dlls into the golang

2024-05-22 Thread Pavan Kumar A R
> > Okay, it's possible to call the C program to Golang. Because I also have > the C platform dlls and the C platform dlls we using in the cross platform > mono and in the mono internally call the.net dlls function , can I use > the C program dlls in Golang? > -- You received this message

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread Kenneth Miller
I tried that, same error On Wednesday, May 22, 2024 at 9:12:58 AM UTC-6 Brian Candler wrote: > It's because the name of the module is "github.com/aclements/go-z3/z3", > not "z3" > > Only packages in the standard library have short names, like "fmt", > "strings" etc. > > On Wednesday 22 May

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread 'Brian Candler' via golang-nuts
It's because the name of the module is "github.com/aclements/go-z3/z3", not "z3" Only packages in the standard library have short names, like "fmt", "strings" etc. On Wednesday 22 May 2024 at 15:46:30 UTC+1 robert engels wrote: > If it is your own code, you have to use > > import

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread robert engels
If it is your own code, you have to use import “github.com/aclements/go-z3/z3 ” or you need a special go.mod file. > On May 22, 2024, at 9:38 AM, robert engels wrote: > > What are you trying to run? z3 is a library. > >> On May 22, 2024, at 9:29 AM,

Re: [go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread robert engels
What are you trying to run? z3 is a library. > On May 22, 2024, at 9:29 AM, Kenneth Miller > wrote: > > I did go get -u github.com/aclements/go-z3/z3 > > but when I go run . I get > > main.go:5:2: package z3 is not in std > > the offending line is > > import "z3" > > can someone help me

[go-nuts] Errors trying to use external pkg z3

2024-05-22 Thread Kenneth Miller
I did go get -u github.com/aclements/go-z3/z3 but when I go run . I get main.go:5:2: package z3 is not in std the offending line is import "z3" can someone help me please? I'm sure this has been asked before but I couldn't find it -- You received this message because you are subscribed to

[go-nuts] Re: Call the .net dlls into the golang

2024-05-22 Thread 'Carla Pfaff' via golang-nuts
You can't call .NET functions directly from Go. Go programs and .NET have two completely different runtimes. You would need some form of inter-process communication (IPC). On Wednesday 22 May 2024 at 14:31:04 UTC+2 Pavan Kumar A R wrote: > Hello , > > I build the.net dlls in the target

[go-nuts] Call the .net dlls into the golang

2024-05-22 Thread Pavan Kumar A R
Hello , I build the.net dlls in the target framework, which is.net-framework 2.0, and inside the.net dlls are some functions. I want to call this function in Golang. How can I call the.net function in Golang? Please help out here. -- You received this message because you are subscribed to

[go-nuts] Re: Discover go-size-analyzer: Streamline Your Go Binary Insights

2024-05-22 Thread Peter Galbavy
Another thumbs up! Thanks On Tuesday 21 May 2024 at 16:16:54 UTC+1 Zxilly Chou wrote: > Hello go-nuts, > > I'm excited to share a new tool that has landed in our Go ecosystem: > go-size-analyzer. This utility is designed to give you a clear picture of > the size of your compi

[go-nuts] Re: replacement for filepath.HasPrefix?

2024-05-21 Thread Jason E. Aten
When I needed to follow symlinks and exclude application-specific directories, I ended up copying and customizing Walk() and walk() from the filepath package. They are short and it was a straightforward to adapt them to my needs.

[go-nuts] Re: Uses of reflect and unsafe packages

2024-05-21 Thread Jason E. Aten
I use "unsafe" for performance optimization and with Cgo[1][2][3]. I use "reflect" and "unsafe" for doing de-serialization in a serialization framework, and for cross-language work (Go <-> C, Go <-> scripting languages like Python, R, Lua, zygomys)[4][5][6]. If you are staying entirely

Re: [go-nuts] Calling the .net dlls to the golang

2024-05-21 Thread peterGo
Kurtis Rader, The OP's question: "I am new to Golang. I have the.net dlls, and I am trying to call the.net function in the dll in Golang. but its not working and i searching in the Google also i could not find the relavent information, please me out here and provide the sample program also"

Re: [go-nuts] Calling the .net dlls to the golang

2024-05-21 Thread peterGo
Kurtis Rader, Please follow the Go Community Code of Conduct while posting here. In short: - Treat everyone with respect and kindness. - Be thoughtful in how you communicate. - Don’t be destructive or inflammatory. - You are fired from your

Re: [go-nuts] Calling the .net dlls to the golang

2024-05-21 Thread Kurtis Rader
Since the question is incoherent and the link to the package you claim to be using doesn't resolve to a valid host name I'm going to assume this is spam and you're not really a person asking for help. P.S., Saying it "is not working" is meaningless. If you are a real person asking for help show

[go-nuts] Re: vet: Respect PATH

2024-05-21 Thread andrew.p...@gmail.com
Same request for goimports. func GoImports(args ...string) error { mg.Deps(CollectGoFiles) for pth := range CollectedGoFiles { cmd := exec.Command("goimports") cmd.Args = append(cmd.Args, args...) cmd.Args = append(cmd.Args, pth) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err :=

[go-nuts] Re: vet: Respect PATH

2024-05-21 Thread andrew.p...@gmail.com
Similar request for gofmt. It should accept the ordinary ./... Go project recursion syntax, instead of the awkward, explicit: func GoFmt(args ...string) error { mg.Deps(CollectGoFiles) for pth := range CollectedGoFiles { cmd := exec.Command("gofmt") cmd.Args = append(cmd.Args, args...) cmd.Args

Re: [go-nuts] Discover go-size-analyzer: Streamline Your Go Binary Insights

2024-05-21 Thread Luca Pascali
Nice PSK On Tue, May 21, 2024 at 5:17 PM Zxilly Chou wrote: > Hello go-nuts, > > I'm excited to share a new tool that has landed in our Go ecosystem: > go-size-analyzer. This utility is designed to give you a clear picture of > the size of your compiled Go binaries, with

[go-nuts] vet: Respect PATH

2024-05-21 Thread andrew.p...@gmail.com
go vet fails to obey the standard PATH environment variable (POSIX, Windows). This makes it unnecessarily cumbersome to use go vet. Here is an example (Mage) script to scan Go projects for variable shadowing: func GoVetShadow(args ...string) error { shadowPath, err := exec.LookPath("shadow")

[go-nuts] Discover go-size-analyzer: Streamline Your Go Binary Insights

2024-05-21 Thread Zxilly Chou
Hello go-nuts, I'm excited to share a new tool that has landed in our Go ecosystem: go-size-analyzer. This utility is designed to give you a clear picture of the size of your compiled Go binaries, with a focus on how dependencies contribute to the overall footprint. It simplifies

[go-nuts] Uses of reflect and unsafe packages

2024-05-21 Thread Ketan Rathod
I have seen many discussions using refflect and unsafe packages, so i am curious to know their usecases and when it is useful to use this packages. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Calling the .net dlls to the golang

2024-05-21 Thread Pavan Kumar A R
Hello , I am new to Golang. I have the.net dlls, and I am trying to call the.net function in the dll in Golang. but its not working and i searching in the Google also i could not find the relavent information, please me out here and provide the sample program also Thanks for the advance. --

[go-nuts] Re: Alternative text/template function libraries to github.com/Masterminds/sprig?

2024-05-20 Thread twp...@gmail.com
Just following up on this old message, there now seems to be at least: https://github.com/go-sprout/sprout https://github.com/chezmoi/templatefuncs Regards, Tom On Monday, January 9, 2023 at 8:53:41 PM UTC+1 Tom Payne wrote: > github.com/Masterminds/sprig is a popular library of template

Re: [go-nuts] using runtime cgo.Handle passing struct types

2024-05-19 Thread Sudarshan Soma
Thanks Ian, Yes i followed a similar approach and it's working fine.. On Sun, May 19, 2024 at 4:36 AM Ian Lance Taylor wrote: > On Thu, May 16, 2024 at 12:57 AM Pavan wrote: > > > > Thanks . Yes it works when C API takes uintptr_t. In my case, the C API > expects void * which i can not change,

Re: [go-nuts] using runtime cgo.Handle passing struct types

2024-05-18 Thread Ian Lance Taylor
On Thu, May 16, 2024 at 12:57 AM Pavan wrote: > > Thanks . Yes it works when C API takes uintptr_t. In my case, the C API > expects void * which i can not change, so I was trying to make it work with > the variant example stated above. In C, unlike Go, you can convert between void* and

[go-nuts] Re: replacement for filepath.HasPrefix?

2024-05-16 Thread peterGo
Jochen, "the first step is to define exactly what the function should do." path/filepath: fix HasPrefix #18358 https://github.com/golang/go/issues/18358#issuecomment-497728574 Peter On Thursday, May 16, 2024 at 7:15:45 AM UTC-4 Jochen Voss wrote: > Dear all, > > filepath.HasPrefix is

[go-nuts] replacement for filepath.HasPrefix?

2024-05-16 Thread Jochen Voss
Dear all, filepath.HasPrefix is deprecated, because it doesn't alway work. What would be a replacement for this function, which at least respects path boundaries, and maybe also ignores case when needed? All the best, Jochen -- You received this message because you are subscribed to the

Re: [go-nuts] using runtime cgo.Handle passing struct types

2024-05-16 Thread Pavan
Thanks . Yes it works when C API takes uintptr_t. In my case, the C API expects void * which i can not change, so I was trying to make it work with the variant example stated above. On Thursday, May 16, 2024 at 5:28:55 AM UTC+5:30 Ian Lance Taylor wrote: > On Tue, May 14, 2024 at 10:37 PM

Re: [go-nuts] using runtime cgo.Handle passing struct types

2024-05-15 Thread Ian Lance Taylor
On Tue, May 14, 2024 at 10:37 PM Pavan wrote: > > I need to pass value of struct type, which has C strings and functions to C > function as void* argument. C layer would provide this struct type data back > to go function. Below is the sample program. It panics if the handle used is >

Re: [go-nuts] Re: programmatic way to find if application go binary is built with -cover flag ?

2024-05-15 Thread 肖华冬
There is possibly a way to do this by parsing strings in the binary. Because when -cover is enabled, go will insert instrumentation statements into the source code, thus the resulting binary would contain these info.On May 14, 2024, at 17:19, Akash Kumar wrote:I unable to find a flag from

[go-nuts] SFTPGo 2.6.0 Released

2024-05-15 Thread Nicola Murino
Hi all, I'm pleased to announce SFTPGo 2.6.0! SFTPGo is an event-driven file transfer solution. It support multiple protocols (SFTP, SCP, FTP/S, WebDAV, HTTP/S) and multiple storage backends. Main new features: - Rewritten WebClient and WebAdmin UIs: we hope you find these new user

Re: [go-nuts] Re: raw bit types without arithmetic

2024-05-15 Thread 'Kevin Chowski' via golang-nuts
By the way - I definitely don't feel strongly about this, and I am just guessing that it's more likely to support new operators for existing types than it is to create new built-in types. I think bitsN types are fine, although again I don't know if I'd personally ever use them. But I am

[go-nuts] Runtime error with golang 1.22.x

2024-05-15 Thread Masanori Matsumoto
Since updating golang to v1.22, I'm getting errors in my tests using pact-go. So I raised issue to the pact-go repository: https://github.com/pact-foundation/pact-go/issues/402 The error is as follows: --- runtime: g 19: unexpected return pc for

[go-nuts] tls.VerifyClientCertIfGiven

2024-05-15 Thread Jochen Voss
Hello, In a server I use tls.Config.ClientAuth=tls.VerifyClientCertIfGiven. If then a client manages to connect and I can see a certificate in http.Request.TLS.PeerCertificates, does this just mean that the client has the certificate, or does this also prove that the client has the associated

[go-nuts] using runtime cgo.Handle passing struct types

2024-05-14 Thread Pavan
Hi, I need to pass value of struct type, which has C strings and functions to C function as void* argument. C layer would provide this struct type data back to go function. Below is the sample program. It panics if the handle used is returned from getH function. It works fine if the handle is

Re: [go-nuts] Re: raw bit types without arithmetic

2024-05-14 Thread jimmy frasche
Arrays are arrays regardless of what they're arrays of. So it would be strange for arrays of certain things to have properties that other arrays don't have and bitwise ops don't make sense for arrays of, say, strings. Also some processors support these sizes natively but wouldn't support a

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-14 Thread 'Keith Randall' via golang-nuts
Your test is benchmarking int->any conversions more than it is testing the underlying modulo/mask difference. When you pass an integer to Enqueue, it is converted to any, which (usually) involves an allocation. That will swamp the cost of any single arithmetic operation. There are a few ways

[go-nuts] Re: programmatic way to find if application go binary is built with -cover flag ?

2024-05-14 Thread Akash Kumar
I unable to find a flag from corresponds to -cover in the result returned from debug.buildInfo On Monday, May 13, 2024 at 10:51:33 PM UTC+5:30 Tamás Gulácsi wrote: > runtime/debug.ReadBuildInfo is a good source of truth: > $ strings bin/godeb|grep '^build\s' > > build -buildmode=exe > build

[go-nuts] Re: raw bit types without arithmetic

2024-05-13 Thread Kevin Chowski
Sorry, sent too early. Obviously that doesn't support the bitwise type conversion you mentioned; I don't really have an opinion on that one, I don't really convert from float to bits very often. It seems like the compiler optimizations you mention could happen with or without these extra

[go-nuts] Re: raw bit types without arithmetic

2024-05-13 Thread Kevin Chowski
How about just allowing bitwise operations on byte arrays (of the same length)? On Monday, May 13, 2024 at 2:51:19 PM UTC-6 jimmy frasche wrote: > I'm not 100% sure if this is a good idea but it's been knocking around > in my head all week so I thought I'd share in case it has any merit: > >

[go-nuts] raw bit types without arithmetic

2024-05-13 Thread jimmy frasche
I'm not 100% sure if this is a good idea but it's been knocking around in my head all week so I thought I'd share in case it has any merit: Introduce bitsN types for N=8, 16, 32, 64, 128, 256, and 512. These are similar to uintN but they are unordered and have no arithmetic operations defined.

[go-nuts] Re: programmatic way to find if application go binary is built with -cover flag ?

2024-05-13 Thread Tamás Gulácsi
runtime/debug.ReadBuildInfo is a good source of truth: $ strings bin/godeb|grep '^build\s' build -buildmode=exe build -compiler=gc build DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 build CGO_ENABLED=1 build CGO_CFLAGS= build

Re: [go-nuts] Re: VCS Stamping - How To Use It? How to debug failures?

2024-05-13 Thread Adam Kaplan
I forgot to add one more detail - the go-toolset image defaults to running as user "default" (UID 1001). Adding `USER root` right after the `FROM` declaration is another way to work around the issue I described, but from a security perspective I would advise against it. On Mon, May 13, 2024 at

Re: [go-nuts] Re: VCS Stamping - How To Use It? How to debug failures?

2024-05-13 Thread Adam Kaplan
Great suggestion Jason - adding `git status` took me in a very unexpected direction, and ultimately a solution. tl;dr if your build's base container image does not use root/uid 0, git commands won't work unless you add the `--chown=` flag to your `COPY` instruction. Go builds need this if you

[go-nuts] Re: programmatic way to find if application go binary is built with -cover flag ?

2024-05-13 Thread Akash Kumar
I am writing an external go program that will take the path to another go binary as argument, and checks if the binary was built with cover flag. `debug.ReadBuildInfo()` is meant for getting build info embedded in the running binary as > ReadBuildInfo returns the build information embedded in

[go-nuts] Re: programmatic way to find if application go binary is built with -cover flag ?

2024-05-13 Thread Zxilly Chou
try debug.ReadBuildInfo(), then iterate the pair in the buildinfo.Settings 在2024年5月13日星期一 UTC+8 20:56:51 写道: > Is there a way in go to find whether a go binary is built with -cover flag > ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] programmatic way to find if application go binary is built with -cover flag ?

2024-05-13 Thread Akash Kumar
Is there a way in go to find whether a go binary is built with -cover flag ? -- 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

[go-nuts] Re: question about src/cmd/go/internal/script/cmds_posix.go and windows

2024-05-13 Thread peterGo
Hiroaki, go/src/cmd/go/internal/test/test_nonunix.go //go:build !unix package test func isETXTBSY(err error) bool { // syscall.ETXTBSY is only meaningful on Unix platforms. return false } peter On Monday, May 13, 2024 at 4:32:38 AM UTC-4 hnak...@gmail.com wrote: > Hi, > I found that > >

[go-nuts] Re: question about src/cmd/go/internal/script/cmds_posix.go and windows

2024-05-13 Thread peterGo
Hiroaki, go/src/syscall/zerrors_windows.go // Invented values to support what package os and others expects. const ( ... ETXTBSY ... ) peter On Monday, May 13, 2024 at 4:32:38 AM UTC-4 hnak...@gmail.com wrote: > Hi, > I found that > >

[go-nuts] question about src/cmd/go/internal/script/cmds_posix.go and windows

2024-05-13 Thread hnak...@gmail.com
Hi, I found that https://github.com/golang/go/blob/07fc59199b9522bfe0d14f35c4391394efc336c9/src/cmd/go/internal/script/cmds_posix.go has the build tag //go:build unix || windows Is windows really needed here? (I suppose not) isETXTBSY is also defined in

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread robert engels
Hi. This is still not correct. Use the “for.. in b.N” as discussed in the blog in order to understand the per op difference - which will be more accurate for a microbenchmark timing, But, if you really want to make a case that bit mask is slower than mod, then a simpler test would be better -

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread Yuta MIYAKE
Thank you. This is benchstat result. new test code follows: ❯ go test -test.bench BenchmarkTestSingleModulo -count=10 -cpu=1 > modulo.txt ❯ go test -test.bench BenchmarkTestSingleBitMask -count=10 -cpu=1 > bitmask.txt ❯ benchstat modulo.txt bitmask.txt goos: darwin goarch: arm64 pkg:

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread leon
Thank you so much. 2024年5月13日月曜日 12:58:09 UTC+9 Kurtis Rader: > On my Apple Studio system the difference in speed is barely measurable and > sometimes the bitmask implementation is faster: > > macpro ~/experiment > go run ring.go > 10 ops in 5092 ms > 10 ops in 5140 ms >

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread Kurtis Rader
On my Apple Studio system the difference in speed is barely measurable and sometimes the bitmask implementation is faster: macpro ~/experiment > go run ring.go 10 ops in 5092 ms 10 ops in 5140 ms macpro ~/experiment > go run ring.go 10 ops in 5080 ms 10 ops

Re: [go-nuts] Bitmask is slower than modulo calculation

2024-05-12 Thread robert engels
Use the Go benchmarking facilities, see https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go > On May 11, 2024, at 9:57 PM, leon wrote: > > I'm trying to prove an optimization technique for ring buffer is effective. > One of the technique is using bitmask instead of modulo to

  1   2   3   4   5   6   7   8   9   10   >