[go-nuts] Re: go build of a *_unix.go file still used under windows ?

2023-09-01 Thread Peter Galbavy
: finding a comprehensive list of GOOS and GOARCH values is a bit > tricker. You can run "go tool dist list", or there are third-party > summaries like > https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 > > On Thursday, 31 August 2023 at 10:44:14 UTC+1 Pet

[go-nuts] go build of a *_unix.go file still used under windows ?

2023-08-31 Thread Peter Galbavy
I have used comment level build constraints for a while but I moved to using _linux.go and _windows.go over time as it makes it clearer for external viewing. A user reported they tried to build on MacOS and of course this didn't work. I renamed the _linux.go files to _unix.go suffixes but then

[go-nuts] Re: go build of a *_unix.go file still used under windows ?

2023-08-31 Thread Peter Galbavy
ursday, 31 August 2023 at 10:13:12 UTC+1 Brian Candler wrote: > https://github.com/golang/go/issues/51572 > > On Thursday, 31 August 2023 at 08:57:15 UTC+1 Peter Galbavy wrote: > >> I have used comment level build constraints for a while but I moved to >> using _

[go-nuts] Re: Parsing difficult JSON

2023-09-14 Thread Peter Galbavy
You will need to create a custom type and unmarshal method. Plenty of example if you search for "golang custom json unmarshal". As I've only had to implement it for a couple of simple types I can't offer my own valid example. On Thursday, 14 September 2023 at 14:36:12 UTC+1 Tobias Klausmann

[go-nuts] Re: Recommended way to distribute pre-compiled C-dependencies for modules using CGO ?

2023-10-11 Thread Peter Galbavy
: > >> Thanks Peter, but I don't follow ... I also use docker to build the >> pre-built binaries. >> >> But how do you distribute them, so folks using your library don't think >> to install them ? >> >> On Wednesday, October 11, 2023 at 12:32:

[go-nuts] Re: Recommended way to distribute pre-compiled C-dependencies for modules using CGO ?

2023-10-11 Thread Peter Galbavy
I use a docker container (golang:bullseye seems the most compatible) and build static binaries. This is feasible as long as your dependencies do not require dynamic loading of dependencies. Poor (my Dockerfile skills) example here: https://github.com/ITRS-Group/cordial/blob/main/Dockerfile

[go-nuts] Re: Recommended way to distribute pre-compiled C-dependencies for modules using CGO ?

2023-10-11 Thread Peter Galbavy
Hang on - I missed your original statement that you are building *libraries* yourself. I am building executables. Sorry for the confusion and my too-fast scan reading! On Wednesday, 11 October 2023 at 12:08:53 UTC+1 Peter Galbavy wrote: > If you link statically, e.g. from my Dockerf

[go-nuts] Re: Blog: Calculating type sets is harder than you think

2022-05-17 Thread Peter Galbavy
I am neither enough of a Go expert ("yet) - I hope) or good enough in real math to say much apart from that is actually one of the clearest explanations of P/NP problems and the actual meaning of CNF/DNF that I have had the pleasure to read. Even setting aside the importance to the design

[go-nuts] Re: Installing a package with an associated command

2022-05-25 Thread Peter Galbavy
It's worth noting that @latest only works for "releases" and not for tags/releases labelled pre-release. Just in case anyone hits the same issue I did a while back! :) On Wednesday, 25 May 2022 at 07:40:04 UTC+1 Volker Dobler wrote: > If you want the command to be installed: Why don't you

Re: [go-nuts] passing a string slice to a variadic function expecting []interface{} or []any

2022-06-22 Thread Peter Galbavy
Thanks for setting my mind at ease. On Wednesday, 22 June 2022 at 16:05:17 UTC+1 axel.wa...@googlemail.com wrote: > No, there is no way to do it. You have to make a copy of the slice as you > did. > > On Wed, Jun 22, 2022 at 4:58 PM Peter Galbavy > wrote: > >>

[go-nuts] passing a string slice to a variadic function expecting []interface{} or []any

2022-06-22 Thread Peter Galbavy
This is probably an FAQ but... I've tried to understand this before but gave up; I am trying to (quick and dirty) import from a CSV or Excel file to a DB and I would like to take the slice from csv.Read() and just pass it through to stmt.Exec() but because the first is a []string and the

[go-nuts] Re: ListenAndServeTLS() (pem and key files for private network)

2022-06-28 Thread Peter Galbavy
If it helps, I put this together for my own project - it's not a package but a bunch of convenience functions/methods for generating TLS certs and keys (there is a lot of implementation specific stuff), but the general shape may help you:

[go-nuts] Re: Which is the most efficient way to read STDIN lines 100s of MB long and tens of MB info is passed to it?

2022-05-08 Thread Peter Galbavy
Rather than overthink it at this stage, just use bufio.Scanner and strings.Contains() and see what performance is like. I suspect that for a plain string and a large-ish file it will be about as good as it gets. On Sunday, 8 May 2022 at 09:36:15 UTC+1 Tamás Gulácsi wrote: > If that "100s of

[go-nuts] Re: Creating and Accessing DLL methods in GO

2022-09-29 Thread Peter Galbavy
Oh, hang on, please ignore my last message. It's that was because the *caller* was defined that way - it's NOT a Go thing. Oops, my bad. Peter On Thursday, 29 September 2022 at 10:33:23 UTC+1 Peter Galbavy wrote: > On Linux at least - I have not tried building or using a Windows DLL,

[go-nuts] Re: Creating and Accessing DLL methods in GO

2022-09-29 Thread Peter Galbavy
On Linux at least - I have not tried building or using a Windows DLL, you have to accept C-style args and process them in the exported function signature: e.g. //export SendMail func SendMail(n C.int, args **C.char) C.int { conf := parseArgs(n, args) ... Here my parseArgs() func loops

[go-nuts] go runtime in shared libs functions called in threads

2022-10-19 Thread Peter Galbavy
I have built a shared lib in Go to replace an old thing we use to send email - mainly to modernise things and add TLS and authentication. We run each call to the entry point in it's own thread in the main program. I am both curious but also concerned about what happens here with go runtimes. I

Re: [go-nuts] Integration testing program that internally forks itself

2022-10-28 Thread Peter Galbavy
I also use a flag to do this, and I have a local package that then removes this flag (or any of a defined list) before re-execing the binary: https://github.com/ITRS-Group/cordial/tree/main/pkg/process https://pkg.go.dev/github.com/itrs-group/cordial/pkg/process#Daemon It may not be perfect,

Re: [go-nuts] go runtime in shared libs functions called in threads

2022-10-20 Thread Peter Galbavy
Thanks for the detail. We cannot change the calling program, just conform to it's API, so it's one function call per email send event and each in it's own (new) thread. On Thursday, 20 October 2022 at 12:28:12 UTC+1 Konstantin Khomoutov wrote: > On Wed, Oct 19, 2022 at 06:28:20AM -0700, Pe

[go-nuts] Re: Single Job to Multi Job

2022-09-20 Thread Peter Galbavy
A good starting point is to look for a multiplxer / multiplexor On Saturday, 17 September 2022 at 11:59:11 UTC+1 ramki...@hotmail.com wrote: > I have a tcp server that collects jobs (lets say 10), and tcp clients get > the jobs. This is done in a FIFO method, where the first job the server >

[go-nuts] Re: Encrypting credentials config file in production and pseudo key rotation

2022-10-01 Thread Peter Galbavy
We have a different requirement, which is opaquing of credentials in user visible config files. The company I work for has a basic way of doing this in the "real" product and I followed the same model for compatibility. There is, as yet, no auto rotation. Basically, we generate an OpenSSL

Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread Peter Galbavy
When you use cmd, err := exec.Command(...) you then set-up it's environment before execution by setting cmd.Env: cmd.Env = append(os.Environ(), `PATH="..."`) and only then run the command: out, err := cmd.Output() if err ... { ... } fmt.Println("output:", out) The above mostly from

Re: [go-nuts] Re: Golang Github Package References

2022-12-05 Thread Peter Galbavy
Also, if you are concerned about the availability of the packages in the future, use vendoring to pull in a copy of the sources to the repo: https://go.dev/ref/mod#go-mod-vendor Peter On Monday, 5 December 2022 at 13:35:25 UTC Brian Candler wrote: > On Monday, 5 December 2022 at 13:12:26 UTC

[go-nuts] Re: Retrieve Path Parameters using inbuild http/Net package

2022-11-17 Thread Peter Galbavy
If you look in the http.Request passed to your handler, there is a URL field - use the net/url package to pull this out: https://pkg.go.dev/net/url#URL On Wednesday, 16 November 2022 at 09:08:38 UTC squadglad...@gmail.com wrote: > Hello Everyone, > > I'm developing a http server using inbuilt

[go-nuts] Re: regexp question

2023-02-10 Thread Peter Galbavy
FindAllStringSubmatch() ? https://pkg.go.dev/regexp#Regexp.FindAllStringSubmatch On Friday, 10 February 2023 at 12:52:34 UTC Jochen Voss wrote: > Dear all, > > What happens if a group in a regular expression matches repeatedly, via > the * operator? Experimentally I found that

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread Peter Galbavy
As a slight digression - I thought I was going mad, but 'slices' and 'maps' are new :-) Only in 1.21 though... Well, there is a lot of boiler plate that maps.Keys() will get rid of. On Thursday, 13 July 2023 at 10:06:01 UTC+1 Brian Candler wrote: > Structs are already comparable, but all

Re: [go-nuts] how to close a child process after father process be killed

2023-07-06 Thread Peter Galbavy
Yes, setsid combined with cmd.Process.Release() works for me. My local / specific needs code is https://github.com/ITRS-Group/cordial/blob/ad18bfbfa44eff1b9b66408394dd83749da25bb1/pkg/process/process.go#L64 which works well for everything I have thrown at it (on Linux). On Wednesday, 5 July

[go-nuts] Re: Is there a good way to make binary files compiled on a high-version machine run on a low-version machine?

2023-08-11 Thread Peter Galbavy
I use a docker container with a centos7 image and build my shared libs there; https://github.com/ITRS-Group/cordial/blob/4f119f7893c67b817baaad23ed75b1ba134bf9c2/Dockerfile#L35 (pls don't judge my Dockerfile skills, it's a learning experience ;) ) On Thursday, 10 August 2023 at 11:12:23 UTC+1

Re: [go-nuts] Export fs.FS as FUSE fs

2023-06-29 Thread Peter Galbavy
I can see a use - exporting an embedded FS (read only) from a binary, especially for testing stuff. On Thursday, 29 June 2023 at 08:00:18 UTC+1 Roland Müller wrote: > Hello, > I am struggling to understand the purpose of extension. > FS is an interface to access file systems from go code. Is

[go-nuts] regexp docs for 'Index' ?

2023-12-14 Thread Peter Galbavy
I noticed today that the regexp docs read: If 'Index' is present, matches and submatches are identified by byte index pairs within the input string: result[2*n:2*n+2] identifies the indexes of the nth submatch. I think that should be result[2*n:2*n+1] - at least in my code that's how it is

[go-nuts] Re: regexp docs for 'Index' ?

2023-12-14 Thread Peter Galbavy
ber 2023 at 09:06:00 UTC Brian Candler wrote: > [a:b] gives you the elements from a to b-1 inclusive. So if you want the > pair at position x, it has to be [x:x+2] > > https://go.dev/play/p/3nvEfOjdfnj > > On Thursday 14 December 2023 at 08:38:57 UTC Peter Galbavy wrote: > >

[go-nuts] Re: Interface in factory pattern and binary size increasing

2023-11-08 Thread Peter Galbavy
Check the size of dependencies; >From >https://stackoverflow.com/questions/70764915/how-to-check-the-size-of-packages-linked-into-my-go-code > the very last answer suggests: go tool nm -size -sort size EXECUTABLE Which has helped me locate unexpected lumps of imports. You can also build with

Re: [go-nuts] xml to json, parsing xml

2024-04-25 Thread Peter Galbavy
I could really have used the go-xmlstruct a year ago :-) But, if I need to fill in more blanks I will try it! On Thursday 25 April 2024 at 02:24:45 UTC+1 twp...@gmail.com wrote: > You can parse XML and JSON quickly with these tools: > > https://github.com/twpayne/go-xmlstruct >

[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 compiled Go binaries,