[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

[go-nuts] Re: Executing JAR from Go

2024-04-15 Thread Tamás Gulácsi
Another possible error is not setting the CWD (cmd := exec.CommandComntext(); cmd.Dir = `the-dir-where-DigitalSign,jar-is`). Tamás Gulácsi a következőt írta (2024. április 16., kedd, 6:20:50 UTC+2): > What is the _working_ command line? > Ain't something like ```java -cp ..

[go-nuts] Re: Executing JAR from Go

2024-04-15 Thread Tamás Gulácsi
What is the _working_ command line? Ain't something like ```java -cp ... -jar DigitalSign.jar org.Sign``` ? Shivli Srivastava a következőt írta (2024. április 15., hétfő, 13:04:28 UTC+2): > this is my code > > func runCommand(ctx context.Context) (string, error) { > > if

[go-nuts] Re: CMSSignedData in Golang

2024-04-02 Thread Tamás Gulácsi
Earlier questions bubbled up https://pkg.go.dev/github.com/fullsailor/pkcs7?utm_source=godoc#SignedData (https://github.com/smallstep/pkcs7) For the XML canonicalization, you may try https://pkg.go.dev/github.com/lafriks/go-xmldsig/v2#Canonicalizer Shivli Srivastava a következőt írta (2024.

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

2024-03-25 Thread Tamás Gulácsi
I don't really get it. The current documentation says that bespite err!=nil, some data may be read (n!=0). If one obeys this rule, then it will consume the data, then handle the error. If we change then io.Reader's documentation (and all std lib implementations)... Ok, now I may be

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: 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] Re: Passing 2d arrays from Go to C using runtime.Pinner

2024-01-26 Thread Tamás Gulácsi
To convert a Go slice to C array is easy with unsafe.Slice. The problem is that the multi-dimensional C array is an array of pointers (*(*float64)) which cannot travel between the C/Go barrier. In your example, you flatten your slice, and recreate the pointers in that one big slice. You could

[go-nuts] Re: CGO unpinned Go pointer panic

2024-01-08 Thread Tamás Gulácsi
That should work. Are you sure that those ellipses (...) does not contain some other pointers? Brent Bailey a következőt írta (2024. január 8., hétfő, 3:06:35 UTC+1): > I'm trying to pass a pointer to an external C library using Go 1.21 and > get the following runtime panic: > panic: runtime

[go-nuts] Re: [RFC] Syntactic Dissonance

2024-01-06 Thread Tamás Gulácsi
Where does TestObject implement the Comparable interface, esp. the Compare method? I don't see such in that rep. The implemented TestObject.Compare method has different signature: it requests a TestObject, not a Comparable interface, as your spec! This is only the first error. The second is

[go-nuts] Re: Maintaining a connection to Postgresql during database failover

2023-12-31 Thread Tamás Gulácsi
This is just from reading the docs: https://pkg.go.dev/github.com/jackc/pgx/v5@v5.5.1/pgconn#FallbackConfig is a member of https://pkg.go.dev/github.com/jackc/pgx/v5@v5.5.1/pgconn#Config and its comment seems to match your use case. I don;t know AWS RDS how does the failover (when is the

[go-nuts] Re: Is there a Go equivalent to Python's ctypes library?

2023-11-21 Thread Tamás Gulácsi
Which is what? Please share with the golang-nuts list if you've found a solution! Mark a következőt írta (2023. november 21., kedd, 11:54:11 UTC+1): > Thank you, that looks just like what I want. > > On Tuesday, November 21, 2023 at 10:21:14 AM UTC Mark wrote: > >> I would like to be able to

[go-nuts] Re: Golang embed with http and middleware

2023-11-19 Thread Tamás Gulácsi
https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/ is a more comprehensive article on using embed. Tamás Gulácsi a következőt írta (2023. november 20., hétfő, 6:28:44 UTC+1): > You can convert a io/fs.FS to a http FS with http.FS. > For an example, see https://stackoverfl

[go-nuts] Re: Golang embed with http and middleware

2023-11-19 Thread Tamás Gulácsi
You can convert a io/fs.FS to a http FS with http.FS. For an example, see https://stackoverflow.com/a/66248259 Daryl Williams a következőt írta (2023. november 20., hétfő, 0:15:29 UTC+1): > I am trying to find out if the http server can work with the embed > filesystem and also use middleware?

Re: [go-nuts] Is "When in doubt, use a pointer receiver" misleading advice?

2023-11-13 Thread Tamás Gulácsi
I've always try to start with a value receiver, change to pointer receiver (EVERYWHERE - do not mix pointer and value receivers!), when the method modifies the sruct's members (or just have a sync.Mutex member), or used as interface (i.e. error - for comparison to nil) Oliver Lowe a következőt

[go-nuts] Re: Go has stolen several hours from the twentieth century Hungary

2023-10-22 Thread Tamás Gulácsi
0:00:00), which have not existed in Europe/Budapest time zone. Maybe I have to accept this discrepancy for these handful of dates. Any better idea? Tamás Gulácsi a következőt írta (2023. október 22., vasárnap, 15:16:51 UTC+2): > https://go.dev/play/p/qkPmfu1sCyU > > 1954-05-22 > 1980

[go-nuts] Go has stolen several hours from the twentieth century Hungary

2023-10-22 Thread Tamás Gulácsi
(not the nowadays ususal set to 3 at 2 o'clock). I just don't know enough about this, that's why I'm asking. Thanks in advance, Tamás Gulácsi -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

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

2023-10-14 Thread Tamás Gulácsi
shion, so that users don't need to one by one figure out how to > install them (and clean up them later if they are no longer using...) ? > > Or maybe there is another convenient way I'm not seeing ? > > > On Thursday, October 12, 2023 at 6:39:34 PM UTC+2 Tamás Gulácsi wrote: > >&

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

2023-10-12 Thread Tamás Gulácsi
Can't you build (make go build for you) those libraries? For example, see github.com/godror/godror just includes the sources of that third party library in an "odpi" subdir, and with ``` /* #cgo CFLAGS: -I./odpi/include -I./odpi/src -I./odpi/embed #include "dpi.c" */ import "C" ``` it is

[go-nuts] Re: Encrypting a small secret using curve25519

2023-09-20 Thread Tamás Gulácsi
https://pkg.go.dev/filippo.io/age offers a simple interface for encrypting/decrypting, with command line, too. christoph...@gmail.com a következőt írta (2023. szeptember 20., szerda, 10:02:24 UTC+2): > Hello, > > I noticed that the go standard library only support ed25519 signing ( >

[go-nuts] Re: [slog] customize defaultHandler

2023-08-29 Thread Tamás Gulácsi
it is not possible (though if I am wrong I would love for someone to > show me how to get it to work.) > > -Mike > > > On Monday, August 28, 2023 at 12:50:50 PM UTC-4 Tamás Gulácsi wrote: > > slog.SetDefault(slog.New(myHandler{Handler:slog.Default().Handler})) > > vl...

[go-nuts] Re: [slog] customize defaultHandler

2023-08-28 Thread Tamás Gulácsi
slog.SetDefault(slog.New(myHandler{Handler:slog.Default().Handler})) vl...@mailbox.org a következőt írta (2023. augusztus 28., hétfő, 15:06:37 UTC+2): > Hi, > > When reading trough the log/slog documentation, it seems one can create > a logger with a different handler, which is either

Re: [go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread Tamás Gulácsi
module is now big because it includes tons of data it didn't use to. > > On Fri, Aug 25, 2023 at 9:53 AM Tamás Gulácsi wrote: > >> go get github.com/pdfcpu/pdf...@v0.5.0 >> <http://github.com/pdfcpu/pdfcpu@v0.5.0> hung, so I've investigated: >> >> $ go get -x

[go-nuts] Why is pdfcpu v0.5.0 290MiB on proxy.golang.org ?

2023-08-25 Thread Tamás Gulácsi
go get github.com/pdfcpu/pdfcpu@v0.5.0 hung, so I've investigated: $ go get -x github.com/pdfcpu/pdfcpu/pkg/api@latest # get http://proxy.golang.org/github.com/@v/list # get http://proxy.golang.org/github.com/pdfcpu/pdfcpu/@v/list # get

[go-nuts] Re: Download large Zip file via sftp

2023-08-23 Thread Tamás Gulácsi
Possibly it's a concurrency error in the sftp library you're using. Compile with "-race" flag and test it - it should print out the offending code. Phillip Siessl a következőt írta (2023. augusztus 23., szerda, 14:37:10 UTC+2): > Hi > > i have some issues when i try to download a larger zip

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

2023-08-09 Thread Tamás Gulácsi
Strange. AFAIK the JSON handler escapes the \n in strings. Joseph Lorenzini a következőt írta (2023. augusztus 8., kedd, 13:24:56 UTC+2): > Thanks that was very helpful. As for your point about slog, yes a custom > handler could but I am using the library json handler. > > I suppose the proper

[go-nuts] Re: How to convert an svg to a png (or gif) image?

2023-08-04 Thread Tamás Gulácsi
https://pkg.go.dev/github.com/goki/gi/svg Mark a következőt írta (2023. augusztus 3., csütörtök, 13:18:48 UTC+2): > I know this has been asked before, just wondered if there were any pure-Go > solutions? > -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: How do library functions that accept a context implement context cancellation inside?

2023-07-21 Thread Tamás Gulácsi
It depends. Checking the context (btw "if err := ctx.Err(); err != nil { return err }" is enough, no need for "select") is cheap but not free. So partition for reasonable sized chunks of work. Tamás Gurunandan Bhat a következőt írta (2023. július 21., péntek, 9:21:15 UTC+2): > Sorry - I meant

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

2023-06-29 Thread Tamás Gulácsi
USE_structure.svg > > Br/Üdvözlettel > Roland > > Am Samstag, 24. Juni 2023 schrieb Tamás Gulácsi : > > Ok, I've put some hours into it, and implemented it: > https://pkg.go.dev/github.com/tgulacsi/g...@v0.25.0/fsfuse > <https://pkg.go.dev/github.com/tgulacsi/go@v0.25.0

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

2023-06-24 Thread Tamás Gulácsi
can export it to some more direct/slimmer repo. Tanás Gulácsi Tamás Gulácsi a következőt írta (2023. június 23., péntek, 8:08:32 UTC+2): > Hi, > > Does anyone know an existing solution for exporting an fs.FS as a FUSE > filesystem? > > As fs.FS is standard now, this woul

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

2023-06-23 Thread Tamás Gulácsi
Hi, Does anyone know an existing solution for exporting an fs.FS as a FUSE filesystem? As fs.FS is standard now, this would open several new possibilities, as a lot of interesting fs.FS implementations exist (zip, tar, DB, embedded, union ), and this one little glue code could export them

[go-nuts] Re: Unit testing slog output

2023-06-14 Thread Tamás Gulácsi
github.com/UNO-SOFT/zlog/v2 NewT(t).SLog() returns an *slog.Logger that uses t.Log for printing. But maybe I don't understand your real problem. shan...@gmail.com a következőt írta (2023. június 14., szerda, 2:14:27 UTC+2): > In the past when I wanted to 'capture' the log output so that I

[go-nuts] Re: smarter way to provide interface capabilities from underlining interface

2023-06-11 Thread Tamás Gulácsi
As Far as I See, you check all the combinations of methods in wideness order. Why not have a generic wrapper struct, that is filled with the underlying driver.Conn's methods, and use that if not nil, but use the generic implementation if not. Like ``` type wrappedConn struct { driver.Conn

[go-nuts] Re: Why does os.RemoveAll ignore ErrNotExists?

2023-04-24 Thread Tamás Gulácsi
You want that path to be fully removed. If it does not exist, then it's already done, nothing to do, the desired result has been achieved (already). xiaq a következőt írta (2023. április 24., hétfő, 16:42:22 UTC+2): > Hi, > > The os.RemoveAll function does not

[go-nuts] Re: Ask about Golang Behavior

2023-03-20 Thread Tamás Gulácsi
You should print cap(newMessage.Biawaks). A nil slice cannot have non-zero capacity. A nil slice and a zero-length slice is semantically equivalent. febriananda pramudita a következőt írta (2023. március 20., hétfő, 16:44:54 UTC+1): > I was playing with protobuf marshaller recently and found

Re: [go-nuts] Re: Looking for a specialized proxy package

2023-03-16 Thread Tamás Gulácsi
As far as I understand, the requirement is to have a link presented by the cloud server, that is proxied to the IOT's HTTP handler. The latter is only on the IOT's localhost, accessible on the cloud server through ssh reverse tunneling (so, a specific port on the cloud server's localhost). This

[go-nuts] Re: Import files with extensions .xls and .xlsx .

2023-02-07 Thread Tamás Gulácsi
Yes, with github.com/extrame/xls and github.com/xuri/excelize/v2 . aadityasha...@gmail.com a következőt írta (2023. február 8., szerda, 7:29:22 UTC+1): > Is it possible to import files with extensions .xls and .xlsx with go ? -- You received this message because you are subscribed to the

Re: [go-nuts] CGO core dump analysis using GDB

2023-01-09 Thread Tamás Gulácsi
I'd create a separate C program, that can be communicated with RPC style - (https://github.com/protobuf-c/protobuf-c-rpc may solve it easily), and have the Go program start it like https://github.com/hashicorp/go-plugin . That way the stack traces and core dumps are separate, each program is

[go-nuts] Re: json encoder with large object (big bytes array)

2022-12-10 Thread Tamás Gulácsi
Not directly, but you can implement sth akin: https://go.dev/play/p/vN2uAp9rRpp With reflection, you can build a helper that uses the exposed MarshalInto on types that implement it, and falls back to Marshal otherwise. jerome@gmail.com a következőt írta (2022. december 10., szombat,

Re: [go-nuts] Re: go:embed question

2022-10-15 Thread Tamás Gulácsi
It won't work iff that file is not there - e.g. it is not commited into the repo. kortschak a következőt írta (2022. október 14., péntek, 10:50:18 UTC+2): > On Fri, 2022-10-14 at 00:17 -0700, esimov wrote: > > . Now, that's not the case when you are running a package using the > > following

[go-nuts] Re: Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-22 Thread Tamás Gulácsi
plain struct error is brittle in other ways, too: you can shoot yourself on foot with "err != nil" check. So: error should be a pointer type. cpu...@gmail.com a következőt írta (2022. szeptember 21., szerda, 21:26:31 UTC+2): > Consider https://go.dev/play/p/jgPMwLRRsqe: > > errors.As(err, )

Re: [go-nuts] Using golang variable in bash script Command

2022-09-19 Thread Tamás Gulácsi
No, please, no! Do NOT use bash with string interpolation if possible! Call find directly: *cmd, err := exec.Command("find", ".", "-name", search)* princ...@gmail.com a következőt írta (2022. szeptember 19., hétfő, 12:04:32 UTC+2): > then we don't need to add these commands > > > > *scanner :=

[go-nuts] Re: Is overwriting contents of pointer field the expected behavior of json.Unmarshal?

2022-08-22 Thread Tamás Gulácsi
"To unmarshal a JSON array into a slice, Unmarshal resets the slice length to zero and then appends each element to the slice." And you gave "" to Unmarshal twice. So it zeroed the length, and appended the second time, effectively overwriting the first (and only) element. This is intended

[go-nuts] Re: gouse — toggle ‘declared but not used’ errors

2022-08-08 Thread Tamás Gulácsi
This is horrible. The 'declared but not used' error saved me hundreds of times, and for experimenting, adding a "_ = notUsed" or hide the whole part behind an "if false" is not a burden. george...@gmail.com a következőt írta (2022. augusztus 6., szombat, 16:26:33 UTC+2): > Hi everyone! > > I

[go-nuts] Re: goroutine benchmark results interpretation for anonymous func?

2022-06-12 Thread Tamás Gulácsi
ch <- bytes.Contains(b.Bytes()[start:end], find) select { case <-quit: quit <- "bye" return } Don't you want a "default:" case in there? This way all your goroutines are kept alive and waiting for that quit -

[go-nuts] Re: Best coding practice for resiliient client-server communications

2022-05-25 Thread Tamás Gulácsi
I bet on https://pkg.go.dev/github.com/rogpeppe/retry - it allows a simple for iter := strategy.Start(); iter.Next(ctx.Done()); { if err := todo(ctx); err == nil { break } else if permanent(err) { break } } portt...@gmail.com a következőt írta (2022. május 25., szerda, 16:02:16

[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 Tamás Gulácsi
If that "100s of MB" is acceptable to be in memory, then bufio.Scanner with properly sized scanner.Buffer is the easiest and battle tested solution. If not, then you have to reimplement the same, with a temp file as a buffer: read input, store in file, seeking to the start on each '\n',

[go-nuts] Re: How to format hour in 24h format without leading 0 ?

2022-04-25 Thread Tamás Gulácsi
strings.Replace(t.Format(time.RFC3339), "T0", "T", 1) ? christoph...@gmail.com a következőt írta (2022. április 25., hétfő, 18:10:45 UTC+2): > I need to format a time stamp hours in 24h format but without leading 0. > This means 7 -> "7" and 17 -> "17". > > For 24h values, the only formatting

[go-nuts] ZipFS using testing/fstest#MapFS

2022-03-24 Thread Tamás Gulácsi
copy it as-is. Is the included comment enough, and can it be used under Apache-2.0 license, or should I keep the BSD license for this code? https://github.com/tgulacsi/go/blob/v0.19.7/zipfs/zipfs.go#L64-L70 Thanks, Tamás Gulácsi -- You received this message because you are subscribed

[go-nuts] Re: Pod memory keeps on increasing and restart with error OOMKilled

2022-03-10 Thread Tamás Gulácsi
gopkg.in/confluentinc/confluent-kafka-go.v1/kafka._Cfunc_GoBytes says it uses cgo, hiding it's memory usage from Go. I bet that 900MiB of memory is there... Rakesh K R a következőt írta (2022. március 10., csütörtök, 7:26:57 UTC+1): > HI, > I have a micro service application deployed on

[go-nuts] Re: Download a zip file from a URL

2022-03-10 Thread Tamás Gulácsi
You miss the error returned by out.Close(). So, finish DownloadFile with "return out.Close()" And os.Create will truncate the file, no need to Remove it - though if you want to remove, just "_ = os.Remove(filepath) "- don't check the error. Gaurav a következőt írta (2022. március 10.,

[go-nuts] Re: how to solve the go.mod conflict when 2 sub-modules point to break version of a common module

2022-03-07 Thread Tamás Gulácsi
Sorry to say, but *go.opentelemetry.io/otel * is a dumpster fire of API breakage and flux. I don't know other solution than modify a or b to use the same version of otel. ian.zh...@gmail.com a következőt írta (2022. március 7., hétfő, 17:49:17 UTC+1): > Hi

Re: [go-nuts] Is there a way to syncronise map reads and writes?

2022-02-22 Thread Tamás Gulácsi
Use a slice instead of a map ? Jason E. Aten a következőt írta (2022. február 23., szerda, 7:10:04 UTC+1): > Unfortunately, that's not how Go maps work. You'll still get races unless > you synchronize even "read-only" maps. > > On Tuesday, February 22, 2022 at 11:59:37 PM UTC-6

[go-nuts] Re: Running golangci-lint run for various different files

2022-01-27 Thread Tamás Gulácsi
Just as with other tools, golangci-lint run runs on packages, not individual files: golangci-lint run ./app ./utils/db Beginner a következőt írta (2022. január 26., szerda, 18:08:28 UTC+1): > Hey when i run golangci-lint run app/main.go utils/db/db.go i get an > error stating `named files

[go-nuts] Re: Drawing millions of images on a bigger canvas

2022-01-22 Thread Tamás Gulácsi
A large canvas needs large amount of memory. 32x35x4 byte is about 4.4Kib, so one million is 4272Mib. Just as your MemProfile says. Either use some image format that can be written in chunks (AFAIK PNG can do this, but that's quite low-level), or mmap the region of the pixels, or leave it to tho

Re: [go-nuts] No time.Duration#UnmarshalText; is there a good reason?

2022-01-19 Thread Tamás Gulácsi
time.Duration.String() already does the pretty printing: https://pkg.go.dev/time@master#Duration.String time.ParseDuration is the parser which could be used in UnmarshalText. rog a következőt írta (2022. január 19., szerda, 12:55:49 UTC+1): > On Wed, 19 Jan 2022 at 04:19, Ian Lance Taylor

Re: [go-nuts] Re: Wrong output for (*http.Request).Write with custom io.ReadCloser body

2022-01-14 Thread Tamás Gulácsi
Why not set Request.ContentLength beforehand (you know it)? dmo...@synack.com a következőt írta (2022. január 14., péntek, 18:56:57 UTC+1): > Sorry to insist, but I think there's also a performance issue with the > current implementation. Given that the service I need to communicate to >

[go-nuts] Re: json: cannot unmarshal object into Go value of type []main.ConnectwiseTicket

2021-12-08 Thread Tamás Gulácsi
Why on earth does everybody paste screenshots about TEXTs??? Please copy-paste simple text as simple text! Color does not convey information, only hides. Your code is readable, but the error message _is_not_. linfr...@gmail.com a következőt írta (2021. december 8., szerda, 18:21:04 UTC+1): >

[go-nuts] Re: How to setup a local directory as a go proxy

2021-11-02 Thread Tamás Gulácsi
What should that server do? I'd check out caddy (caddyserver.com) first. trb...@gmail.com a következőt írta (2021. november 2., kedd, 18:18:16 UTC+1): > I am trying to setup a go proxy based in/on a local directory. > > I can setup and run a number of different go proxies, but I am not sure >

[go-nuts] Re: Trouble with pgx package

2021-10-02 Thread Tamás Gulácsi
Another problem is that INSERT is not a query. Use QueryContext for SELECT statements, and ExecContext for everything else. muhorto...@gmail.com a következőt írta (2021. október 2., szombat, 12:52:44 UTC+2): > Just started making my first web, I don't quite understand the Query Row >

Re: [go-nuts] What is the total max size of embed content?

2021-09-22 Thread Tamás Gulácsi
Go back to the venerable SFX zip archives: Append the file as a (uncompressed?) ZIP file to the Go binary. That binary can then open itself as a ZIP and read/use the database, and every other program will see it as a zip file. Or just simply append the database and its uint64 size to the go

[go-nuts] Re: setuid root

2021-09-20 Thread Tamás Gulácsi
r id not root. But to set the permissions I'd run: 'chmod 4755 > myapplication' > > On Monday, September 20, 2021 at 11:20:39 AM UTC-4 Tamás Gulácsi wrote: > >> You mean "chown root app; chmod 4755 app" ? >> >> Rich a következőt írta (2021. szeptember 20., hétfő, 16:57:

[go-nuts] Re: setuid root

2021-09-20 Thread Tamás Gulácsi
You mean "chown root app; chmod 4755 app" ? Rich a következőt írta (2021. szeptember 20., hétfő, 16:57:38 UTC+2): > I am trying to create a go program so that I can peform an action that is > more complex than the example I have below. I can't give sudo right so run > the application due to

[go-nuts] Re: How to capture the bytes of stdin

2021-08-18 Thread Tamás Gulácsi
You have to io.Copy(cmdStdin, os.Stdin) to use your program's stdin, and pipe it to the subprocess. hyo...@gmail.com a következőt írta (2021. augusztus 18., szerda, 17:50:24 UTC+2): > The goal: I want to capture all the bytes of *cmd.Stdin* and process them > with this rot13 function:

Re: [go-nuts] sql.Row doubt

2021-08-14 Thread Tamás Gulácsi
It could, but what for? sql.Row is already a convenience wrapper for I-know-I-want-only-one-row, so you know what kind of data are you retrieving, but you know it's only one row? daniel...@omie.com.br a következőt írta (2021. augusztus 13., péntek, 19:04:24 UTC+2): > Yes i ever use Query()

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Tamás Gulácsi
First, sort all the bytes (0-255) with Go and .Net, and compare them. For Unicode-unaware sorting, that'd be enough: create a mapping between the two tables, replace all the bytes in the Go's input before sort (or use a Less that does the translation), thus replicating the .NET sort order.

[go-nuts] Re: go list -u -m -json all

2021-07-25 Thread Tamás Gulácsi
go mod download helped me. jerome@gmail.com a következőt írta (2021. július 25., vasárnap, 9:49:40 UTC+2): > > Hello, > I am currently testing `go1.17rc1 linux/amd64` in my dev env. > > With this version `go list -u -m -json all` seems not work anymore (I use > it to know which module is

[go-nuts] Re: Transaction Library Recommendations

2021-07-21 Thread Tamás Gulácsi
Hi, 1. Where are the transactions? I see only "up" and "down", and each can fail - even the "down" after a failed "up". 2. You spawn goroutines, and collect errors using append - that's racy. Run the tests with "-race" and see for yourself! Tamás dtmi...@gmail.com a következőt írta (2021.

Re: [go-nuts] Re: C Third Party Lib CGO

2021-07-09 Thread Tamás Gulácsi
e of uintptr variable, convert it back with > unsafe.Pointer(uintptr) and pass it to a C function, does C not interpret > that as a C pointer pointing to the same address as uintptr holds? > Therefore the conversion should be alright? > > Sorry for not getting it... > > Sandro >

Re: [go-nuts] Re: C Third Party Lib CGO

2021-07-09 Thread Tamás Gulácsi
An uintptr *is not a pointer*, so 2. is false. NOTHING at Go's side holds anything regarding MyAppHwnd, and it doesn't seem to be a pointer at all (just a number), so converting that to an unsafe.Pointer is unsafe. The rules about uintptr are there for a reason! Only the allowed use cases are

[go-nuts] Re: C Third Party Lib CGO

2021-07-08 Thread Tamás Gulácsi
Use *C.MyAppPtr on Go side, don't hide it behind an uintptr. snmed a következőt írta (2021. július 7., szerda, 19:47:44 UTC+2): > > Hi all > > Once again I have a 3th party library which looks like this example: > https://play.golang.org/p/Ue9yQ8s8Ymq and I need it to integrate in our > go

[go-nuts] Re: It's possible to replace cgo memory allocator?

2021-06-12 Thread Tamás Gulácsi
You can use the LD_PRELOAD env var (https://www.ibm.com/docs/en/spectrum-symphony/7.2.1?topic=optimization-optimizing-memory-consumption-tcmalloc-jemalloc) to use jemalloc or tcmalloc, and debug with them. di3go.b...@gmail.com a következőt írta (2021. június 10., csütörtök, 21:19:15 UTC+2):

[go-nuts] Re: Warning for look alike Unicode characters

2021-06-09 Thread Tamás Gulácsi
strings.EqualFold ? Delta a következőt írta (2021. június 9., szerda, 23:30:04 UTC+2): > Does the Go tool has any warning system for look alike Unicode > characters. > > http://www.unicode.org/Public/security/10.0.0/confusables.txt > > > In rustc - > >

[go-nuts] Re: encoding/csv: getting a line number of current record when using csv.Reader

2021-04-09 Thread Tamás Gulácsi
And if your CSV is not so simple, then extract the number of "\n"-s found in the fields from the line count gathered by counting "\n"-s. Or re-encode the csv into a "\n" counting io.Writer. nikolay nikolay a következőt írta (2021. április 9., péntek, 7:03:49 UTC+2): > If you CSV is simple, as

[go-nuts] Re: MUnmap Mmapped file with Finalizer

2021-03-26 Thread Tamás Gulácsi
See https://github.com/tgulacsi/go/blob/master/iohlp/slurp.go But mainly I use it at https://github.com/tgulacsi/go/blob/master/i18nmail/walk.go#L72 so all I want is an io.Reader, thus your example of golang.org/x/exp/mmap returning an io.ReaderAt may be enough, thanks! Brian Candler a

[go-nuts] MUnmap Mmapped file with Finalizer

2021-03-26 Thread Tamás Gulácsi
by the OS, not by the Go GC. So, how to Unmap only when all the references of the backing array gets garbage collected? Or any other idea? Thanks in advance, Tamás Gulácsi -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Some questions about the memory allocation strategy of channel

2021-03-19 Thread Tamás Gulácsi
AFAIK when there's no pointer in elem (the channel's element's type), we can cheat/optimize (call as you wish), and allocate the channel's backing memory AND all it's elements' memory at once, AS A BYTE ARRAY (nil is the second argument of mallocgc). Then we can play unsafe tricks an treat it as

[go-nuts] Re: I want to save a file from an incoming POST request and upon request return the file in a GET request as JSON data.

2021-03-02 Thread Tamás Gulácsi
If I understand correctly, you receive "bodyBytes", store it in a file, and later want to serve it. Then a `w.Write(b)` would suffice. Or without reading the whole file into memory: `io.Copy(w, file)`. hugh@gmail.com a következőt írta (2021. március 2., kedd, 14:12:22 UTC+1): > Here is

[go-nuts] Re: Recommendation for Fuzzed Types without Native On-Disk Format

2021-02-09 Thread Tamás Gulácsi
Use the []byte slice to fill your Table, and use the simplest possible encoding, which uses as few constraints as possible: 1. Attrs on a line, separated by space, k-v separated by colon; 2. Each Entry on a separate line, have the fields encoded as in 1. 3. Decide how often do you want to

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread Tamás Gulácsi
There is a runtime.SetFinalizer, but it is not guaranteed to be run, anytime. The most idiomatic and safe solution is to have a Close() method on the Go side, which frees the C side. You may even add a Finalizer that panics if Close haven't been called before... tokers a következőt írta (2020.

[go-nuts] Re: Any recommendation for structured logging library in Golang?

2020-11-18 Thread Tamás Gulácsi
This format is quite specific - roll your own! See for example https://github.com/shamaazi/antilog or a derivative (github.com/UNO-SOFT/ulog) - very simple code, easy to modify. My experience is against logfmt: is is nice, human-readable, but it is hard to log structures with it - you'll use

Re: [go-nuts] How to drop old value in a channel salety

2020-11-14 Thread Tamás Gulácsi
If you read more than write, then you can use a sync.RWMutex an RLock when reading, Lock when writing. Kurtis Rader a következőt írta (2020. november 15., vasárnap, 6:13:03 UTC+1): > On Sat, Nov 14, 2020 at 8:34 PM Robert Engels > wrote: > >> That wasn’t my take on the OPs need. He said the

[go-nuts] Re: Count of actually "processed" bytes from csv.Reader

2020-10-31 Thread Tamás Gulácsi
the csv.Reader's inner r ! Severyn Lisovsky a következőt írta (2020. október 31., szombat, 18:31:34 UTC+1): > Tamás Gulácsi, this was basically my initial idea to do that, but > unfortunately there is no access to internal bufio.Reader. See: > https://golang.org/src/encoding/csv/reade

[go-nuts] Re: Count of actually "processed" bytes from csv.Reader

2020-10-31 Thread Tamás Gulácsi
Give csv.NewReader your own *bufio.Reader. Regarding (https://pkg.go.dev/pkg/bufio/#NewReaderSize) if the underlying io.Reader is already a *bufio.Reader with a big enough size (and csv.NewReader uses the default 4k), then the underlying reader is used, no new wrapping is introduced. This way

Re: [go-nuts] Should I always call runtime.LockOSThread() before calling C function?

2020-10-25 Thread Tamás Gulácsi
I'd put all that C-calling code in ONE goroution, with runtime.LockOSThread, and send commands to this thread through a channel, with a receiver chan for response, too. This way only one goroutine needs LockOSThread, and only that pays the memory penalty. If it becomes the bottleneck, you can

Re: [go-nuts] Golang slow performance inside for loop MySQL Queries

2020-10-21 Thread Tamás Gulácsi
To reuse connections, and pay the slowness only on the first connection, set Config.DB.SetMaxIdleConns(2) Or something like that. As *sql.DB is a pool, this can keep two connections alive - one for your main query, and one for the per-row extra queries. Bill a következőt írta (2020.

[go-nuts] Re: Table driven tests and error/output testing

2020-10-19 Thread Tamás Gulácsi
Use bytes.Buffer or strings.Builder directly - no need for the bufio.Writer. bufio.Writer only speeds up writing by calling the underlying Writer less, with bigger slices. Here you Write into a memory, just as bufio.Writer. Also, you can save some allocations by creating the buffer once outside

Re: [go-nuts] ERRORLEVEL issue

2020-09-21 Thread Tamás Gulácsi
You're building src_go.exe (-o of go build), and running orabench.exe. walter@gmail.com a következőt írta (2020. szeptember 21., hétfő, 8:51:19 UTC+2): > My code is here: > > [image: Screenshot 2020-09-21 084403.png] > > My script is here: > > > [image: Screenshot 2020-09-21 084604.png] >

Re: [go-nuts] Re: Get request send me hmtl content but works fine from python and curl

2020-09-20 Thread Tamás Gulácsi
Which is absolutely non-standard :) Headers are case-insensitive, so if the server relies on case, it's against the HTTP standard :) remb...@gmail.com a következőt írta (2020. szeptember 20., vasárnap, 13:18:09 UTC+2): > Thanks everyone for your valuable feedback. > I was able to figure out

Re: [go-nuts] Re: Get request send me hmtl content but works fine from python and curl

2020-09-20 Thread Tamás Gulácsi
s > correct. > > Ryan > > > > On Sun, 20 Sep 2020 at 11:10, burak serdar wrote: > >> On Sat, Sep 19, 2020 at 11:47 PM Tamás Gulácsi >> wrote: >> > >> > I bet requests (and curl) encodes the params as multipart/form-data, >> NO

[go-nuts] Re: Get request send me hmtl content but works fine from python and curl

2020-09-19 Thread Tamás Gulácsi
I bet requests (and curl) encodes the params as multipart/form-data, NOT query string. Do the same: https://play.golang.org/p/L4YryKNjju4 remb...@gmail.com a következőt írta (2020. szeptember 19., szombat, 20:44:54 UTC+2): > I am trying to call a simple api by using golang. But, each time it

Re: [go-nuts] Catch/handle cgo SIGSEGV

2020-09-18 Thread Tamás Gulácsi
020 at 12:09 PM Tamás Gulácsi wrote: > > > > Can you provide some skim of a C-side signal handler that could induce a > Go panic? > > All I want is to have an error on Go side, instead of a crash (though it > may be safer to have a crash...). > > I can't think of any

Re: [go-nuts] Catch/handle cgo SIGSEGV

2020-09-17 Thread Tamás Gulácsi
:52 UTC+2): > On Thu, Sep 17, 2020 at 8:52 AM Tamás Gulácsi wrote: > > > > I'm searching for help in https://github.com/godror/godror/issues/100 - > I've added a recover, called debug.SetPanicOnFault, without success: the > extra free still panics with SIGSEGV, and the r

[go-nuts] Catch/handle cgo SIGSEGV

2020-09-17 Thread Tamás Gulácsi
I'm searching for help in https://github.com/godror/godror/issues/100 - I've added a recover, called debug.SetPanicOnFault, without success: the extra free still panics with SIGSEGV, and the recover does not catch it (or I coded it wrongly):

[go-nuts] Re: SQL Do I use Query or Exec?

2020-09-15 Thread Tamás Gulácsi
You can use EXPLAIN in PostgreSQL: # explain with t as (select * from mantis_user_table) update mantis_user_table b set id=id where exists (select 1 from t where t.id = b.id); Update on mantis_user_table b (cost=23.19..41.92 rows=453 width=186) -> Hash Join (cost=23.19..41.92 rows=453

[go-nuts] Re: How to send mail using .EML file/content in Golang?

2020-09-14 Thread Tamás Gulácsi
: ``` type copyWriterTo struct { r io.Reader } func (cw copyWriterTo) WriteTo(w io.Writer) (int64, err) { return io.Copy(w, cw.r) } ``` and use it in `sc.Send`, instead of `buf`. Tamás Gulácsi a következőt írta (2020. szeptember 14., hétfő, 6:17:42 UTC+2): > Use DialSender returned by gomail.Dial

[go-nuts] Re: How to send mail using .EML file/content in Golang?

2020-09-13 Thread Tamás Gulácsi
Use DialSender returned by gomail.Dial. You don't need the parsed message for it, just the from and to addresses, and write the contents of the .eml file into the WriterTo as is. sandip bait a következőt írta (2020. szeptember 14., hétfő, 1:06:50 UTC+2): > I am using Standard *gomail

Re: [go-nuts] database/sql doesn't return error for query-string-destination if NULL bug or feature

2020-09-11 Thread Tamás Gulácsi
database/sql.DB is a pool. If you don't want to close it, SetMaxIdleConns(1), or better, use a db.Conn(). stephan...@gmail.com a következőt írta (2020. szeptember 11., péntek, 21:02:26 UTC+2): > On Friday, 11 September 2020 at 21:04:11 UTC+3 mar...@gmail.com wrote: > >> Which sqlite driver are

[go-nuts] Re: Anyone successfully connecting to Oracle (11g) from Go?

2020-09-07 Thread Tamás Gulácsi
Wow, have you reverse-engineered the Oracle SQL.NET connection? Or the Java thin client? Is this legal at all? Though I'd pay a limb for a C-less native, pure Go client... Samy Sultan a következőt írta (2020. szeptember 7., hétfő, 20:01:46 UTC+2): > I make a new package go-ora it is pure go

Re: [go-nuts] Debug http calls made using go http client

2020-08-23 Thread Tamás Gulácsi
You can print every step with net/http/httptrace 's ClientTrace. krishna...@gmail.com a következőt írta (2020. augusztus 23., vasárnap, 15:55:50 UTC+2): > Hello Dimas, > > Thank you for your response. My application is running in a kubernetes > cluster and I will not be able to run TCPMon or

  1   2   3   4   5   6   >