Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread Brian Candler
In principle I agree with the sentiment, in the sense this is what you'd expect from other languages like Python. However, slices are fundamentally different to maps in Go. Map values contain a pointer to a mutable data structure (that's why you can't insert into a zero map - you have to

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

2023-07-05 Thread Brian Candler
> Is there any way to create a child process that is detached from the original cgroup using exec.Command? > I don't want my child process to be killed when the parent process dies. This might be an issue with process groups, not cgroups, in which case I think Setsid is what you want, something

[go-nuts] Re: how to diagnose slow build

2023-06-29 Thread Brian Candler
What platform are you building under - in particular, is it Windows? On Thursday, 29 June 2023 at 13:11:07 UTC+1 王富民awaw wrote: > My builds have been very slow recently and I want to know why is `go > build` so slow for me. > Is it due to reading disks or something else? > > What is the

Re: [go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread Brian Candler
> You can always solve name spacing issues by splitting it up into separate packages. Or type aliases: https://go.dev/play/p/Slhgs8SLyo6 On Thursday, 15 June 2023 at 09:47:39 UTC+1 Axel Wagner wrote: > Type declarations in functions are only scoped from the point of their > declaration until

[go-nuts] Re: tool for ast graph visualization

2023-06-14 Thread Brian Candler
Aside: draw.io also has functionality like graphviz for the web 2.0 generation: https://drawio-app.com/blog/automatically-create-draw-io-diagrams-from-csv-files/ On Wednesday, 14 June 2023 at 10:01:10 UTC+1 Vraj Reshamdalal wrote: > Hi alex-coder! > You can try using Graphviz. > Graphviz

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

2023-06-12 Thread Brian Candler
On Monday, 12 June 2023 at 07:55:24 UTC+1 Brian Candler wrote: I don't know if it's possible to use 'reflect' to build the struct type dynamically FWIW, I tried it, but could only make a program which crashes spectacularly. https://go.dev/play/p/BIFFT3FgUrz There is a comment

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

2023-06-12 Thread Brian Candler
this can be optimized... May be run profile with all known > sql drivers and create pairs with most used combinations ? > > -- > Vasiliy Tolstov, > e-mail: v.to...@selfip.ru > > > На 11 июня 2023 г., 19:31:01, Brian Candler написали: > >> I think the issu

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

2023-06-11 Thread Brian Candler
I think the issue is that the *consumer* of this object checks whether certain methods (or rather, interfaces) are present, and behaves differently depending whether they are or not. There are a whole load of public interfaces defined here:

Re: [go-nuts] Hard-to-explain race detector report

2023-06-08 Thread Brian Candler
> In this case however, what is reported is a concurrent write-after-read. Is that really a memory race? In general, it would be: if these accesses are not synchronized, there's a risk that the goroutines could slip relative to each other so that the write and read take place at the same time,

[go-nuts] Re: Map and slice are also concurrency-unsafe data structures. Why is map designed to throw a fatal that cannot be recovered when there is a concurrency conflict, but slice does not have any

2023-06-02 Thread Brian Candler
Is it actually "designed" to do that? I think it just crashes when the map data structure is in a corrupted state, because of concurrent updates. In principle, you may be able to get a panic when updating a slice concurrently, but it's much rarer. That's because a slice allocates a contiguous

[go-nuts] Re: Transferring a Go repository and installing old releases

2023-05-26 Thread Brian Candler
that > releases before v0.2.19 need to be installed with the old module name (if > using go install) ? > On Friday, 26 May 2023 at 10:45:39 UTC+1 Tiago de Bem Natel de Moura wrote: > >> Hi Brian, >> >> I updated go.mod and all import paths in the main branch already, b

[go-nuts] Re: Transferring a Go repository and installing old releases

2023-05-26 Thread Brian Candler
What happens if you change the go.mod file, and all imports within the project, to use github.com/new/project instead of github.com/old/project ? (If you make this change, the issue then is whether you can still "go install github.com/old/project...") The reason it works with a local clone is

Re: [go-nuts] Idiomatic distribute-process-collect pattern

2023-05-22 Thread Brian Candler
Isn't Ian's solution basically the same, but using a Waitgroup instead of an Errgroup? I think the Fetch() is just a placeholder for "this is where the implementation detail of the task would go" On Sunday, 21 May 2023 at 21:54:39 UTC+1 Andrew Harris wrote: > The recipe on 10:26 should work

[go-nuts] Re: how do I use go test for code that needs a flag defined in flag package

2023-05-07 Thread Brian Candler
;>> have the correct imports and the top statement, package main. >>>> >>>> Thank you for answering, that's working. >>>> >>>> --rob solomon >>>> >>>> >>>> On Saturday, May 6, 2023 at 11:24:11 AM UTC-

[go-nuts] Re: how do I use go test for code that needs a flag defined in flag package

2023-05-06 Thread Brian Candler
Your code is incomplete (it's missing all the imports), and "go test" doesn't run your main() function anyway, so it's not going to parse the flags. But otherwise I think it would be something like this: (single dash, -args not --args) go test . -v -args - -dots

Re: [go-nuts] FATAL: ThreadSanitizer: unsupported VMA range FATAL: Found 39 - Supported 48 / go: added github.com/docker/docker v23.0.4+incompatible

2023-04-25 Thread Brian Candler
t; -C dir >>change to dir before running command >> -all >>show all documentation for package >> -csymbol matching honors case (paths not affected) >> -cmd >>show symbols with package docs even if package is a command >

Re: [go-nuts] FATAL: ThreadSanitizer: unsupported VMA range FATAL: Found 39 - Supported 48 / go: added github.com/docker/docker v23.0.4+incompatible

2023-04-25 Thread Brian Candler
ackage golang.org/x/tools/cmd/go > go: malformed module path "doc": missing dot in first path element > > > > On Tue, Apr 25, 2023 at 6:16 PM Brian Candler wrote: > >> You're following out-of-date instructions. godoc is now "go doc". >> >&

Re: [go-nuts] FATAL: ThreadSanitizer: unsupported VMA range FATAL: Found 39 - Supported 48 / go: added github.com/docker/docker v23.0.4+incompatible

2023-04-25 Thread Brian Candler
You're following out-of-date instructions. godoc is now "go doc". On Tuesday, 25 April 2023 at 16:52:09 UTC+1 Mario Marietto wrote: > Hello to everyone. > > I've restarted the tutorial from the beginning and I've saved every > command issued : > > $ cd /home/marietto > $ wget

[go-nuts] Re: [Contribution] Go_Updater shellscripting (GNU/Linux or WSL)

2023-04-11 Thread Brian Candler
Something to consider: if you untar over an existing installation, then it's possible you will be left with stale artefacts - e.g. source files that were in an old version that aren't in the new one. I've been bitten by this in other projects. I haven't been bitten by this in Go, but I always

Re: [go-nuts] Is there a golang download for latest patch release like 1.20.x?

2023-04-11 Thread Brian Candler
[Aside: I think it would have been better to start a new thread rather than hijack an unrelated conversation] go.dev and pkg.go.dev both work perfectly for me. Are you able to resolve those names to IP addresses - if so, what? What do you see when you attempt to connect? Do you have a static

[go-nuts] Re: Disable AVX, AVX2, AVX-512, SSE support while building a go binary

2023-04-06 Thread Brian Candler
See https://github.com/golang/go/wiki/MinimumRequirements#amd64 The default is GOAMD64=v1 so the fancy extensions are disabled by default (or guarded). On Thursday, 6 April 2023 at 06:18:03 UTC+1 aditi sinha wrote: > Hi > > I want to build a simple go binary that prints "hello world" but

Re: [go-nuts] Redfining loop variable semantics - what's the plan?

2023-04-04 Thread Brian Candler
On Tuesday, 4 April 2023 at 07:57:58 UTC+1 Marcello H wrote: The "scary" thing is, that if people don't have enough tests, they are probably not aware of such a bug, or can they still be aware somehow? Do you mean bugs due to the *old* behaviour? You're quite right, the first they may be

[go-nuts] Re: Table html + js + golang

2023-04-03 Thread Brian Candler
I suggest you look at the actual request body which the client is sending, using your browser's developer console (or at worst using tcpdump/wireshark, as long as it's not HTTPS). Then it should be clear whether your Javascript is sending a "parcelas" form value, and if so what it contains. I

Re: [go-nuts] getting the size of an io.ReaderAt?

2023-04-01 Thread Brian Candler
Or the caller can wrap the object with io.NewSectionReader <https://pkg.go.dev/io#NewSectionReader>(f, 0, len) On Saturday, 1 April 2023 at 10:51:11 UTC+1 Brian Candler wrote: > Could you make your function accept some other interface? e.g. > > type SizeReaderAt interface { &g

Re: [go-nuts] getting the size of an io.ReaderAt?

2023-04-01 Thread Brian Candler
Could you make your function accept some other interface? e.g. type SizeReaderAt interface { io.ReaderAt Size() int64 } Values of this type will still be able to satisfy io.ReaderAt at point of use. You could also use the existing io.SectionReader

[go-nuts] Re: Ask about Golang Behavior

2023-03-20 Thread Brian Candler
On Monday, 20 March 2023 at 16:15:28 UTC Tamás Gulácsi wrote: You should print cap(newMessage.Biawaks). Good catch on that typo :-) FWIW, here it is as a playground link: https://go.dev/play/p/CHaW3lMutXN -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] How to do a cleanup of context cancelling?

2023-03-19 Thread Brian Candler
I'm pretty sure that code won't code will compile as written. Firstly, http.DefaultClient.Do (req) returns two values, but c is a chan error. Secondly, the second case statement is invalid syntax (case err := f(<-c):) - you can't put a function call in here,

Re: [go-nuts] How to generalize parameters for a function

2023-03-15 Thread Brian Candler
Which is also the reason why you can't insert into a nil map - you have to make() one. On Wednesday, 15 March 2023 at 10:58:09 UTC Dan Kortschak wrote: > On Tue, 2023-03-14 at 19:56 -0700, Kurtis Rader wrote: > > Maps are a special-case. You can't pass them "by value" in the sense > > you mean

[go-nuts] Re: what the asyncPreempt happens in flamegraph mean?

2023-03-15 Thread Brian Candler
[Aside: please don't paste images or coloured text. They're very hard to read] It's perfectly normal for your code to be interrupted once every 10ms or so for async preemption. You'll see a load of system calls, but it should not be making your code run "slowly". If you find that "most of the

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Brian Candler
coded" value. It doesn't mean you should turn it into a string of ASCII "1" and "0" characters. On Tuesday, 14 March 2023 at 11:12:11 UTC Brian Candler wrote: > On Tuesday, 14 March 2023 at 09:26:05 UTC Van Fury wrote: > > Am developing a server (diameter)

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Brian Candler
On Tuesday, 14 March 2023 at 09:26:05 UTC Van Fury wrote: Am developing a server (diameter) which will response with an AVP SIP-Authenticate. In the specification " The SIP-Authenticate AVP is of type OctetString and It shall contain, binary encoded, the concatenation of the authentication

[go-nuts] Re: gomobile bind in win10

2023-03-09 Thread Brian Candler
A bit of Googling and I find: ("android ndk api version" =>) https://developer.android.com/ndk/downloads/revision_history Android NDK r24 *(March 2022)* *Changelog* *...* - Jelly Bean (APIs 16, 17, and 18) is no longer supported. The minimum OS supported by the NDK is KitKat (API level

[go-nuts] Re: pkg.go.dev down?

2023-03-08 Thread Brian Candler
Looks like it: at https://pkg.go.dev/time I see 500 Internal Server Error and a gopher in a biplane. On Wednesday, 8 March 2023 at 13:22:49 UTC Steven Hartland wrote: > Is there an issue with pkg.go.dev atm as packages are failing to load > after a long time with a 500 error for example time

[go-nuts] Re: Nested structs

2023-03-03 Thread Brian Candler
Use pointers. https://go.dev/play/p/V9M_XxX052J On Friday, 3 March 2023 at 13:18:30 UTC BARIKUMA MONDELO wrote: > Is it possible to have two structs both declared in each other, something > like this > > type human struct { > name string > age int > address Address > }

[go-nuts] Re: is ECDHE-RSA-AES256-SHA384 currently supported in Golang?

2023-03-01 Thread Brian Candler
https://go.dev/src/crypto/tls/cipher_suites.go {TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", supportedOnlyTLS12, false}, Looks like it only works with TLS1.2. On Wednesday, 1 March 2023 at 16:15:04 UTC Joe Wickberg wrote: > Hello, > > I've been trying

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime?

2023-01-30 Thread Brian Candler
Here are some more options you could consider. 1. Do what busybox does: put them all into separate packages, link them all into one monster executable, switching on os.Args[0] to decide which main function to run. Then add lots of links or symlinks to the same program so it can be executed

[go-nuts] Re: Endless Running Goroutine Terminates Without Panic

2023-01-26 Thread Brian Candler
On Thursday, 26 January 2023 at 15:38:28 UTC Brian Candler wrote: > As a goroutine may terminate if panic occurs If that happens, it will crash the entire program (go isn't python :-) https://go.dev/play/p/YD3lQ-xWe29 ... although other goroutines may continue for a very short time afterwa

[go-nuts] Re: Endless Running Goroutine Terminates Without Panic

2023-01-26 Thread Brian Candler
> As a goroutine may terminate if panic occurs If that happens, it will crash the entire program (go isn't python :-) https://go.dev/play/p/YD3lQ-xWe29 > I used recover() to log the error and the monitoring thread is re-created. But this doesn't help either. I noticed that the goroutine has

[go-nuts] Re: [Potential Performance issue] Concurrent File upload time is linearly increasing; Need help

2023-01-25 Thread Brian Candler
I don't see any problem there. You've simply started 50 uploads concurrently, and some are completing sooner than others - most likely the ones which got first dibs on the CPU. This is because they're all fighting for the same resources - the CPU, the network, and especially the capacity on

Re: [go-nuts] Pass SQL null values to Parquet

2023-01-23 Thread Brian Candler
If you're using a third-party parquet encoding library, you'll need to pass null/not-null using whatever convention that library requires. I took a quick look at xitongsys/parquet-go's front-page documentation, and it seems it handles null (OPTIONAL) using pointers:

Re: [go-nuts] Re: Wait before Add

2023-01-22 Thread Brian Candler
ve is something else, then there will be a different way to achieve it, depending on what that objective is. On Sunday, 22 January 2023 at 10:10:20 UTC bodqh...@gmail.com wrote: > On 17.01.2023 10:57, Brian Candler wrote: > > You're supposed to do Add(1) -> Wait; and you'd normally wait once, i

[go-nuts] Re: Trying to import etherum in go

2023-01-21 Thread Brian Candler
The error is correct. Your code says to import "github.com/ethereum/go-ethereum/ethash" but if you browse to https://github.com/ethereum/go-ethereum you'll see there is no "ethash" subdirectory. On Saturday, 21 January 2023 at 14:17:01 UTC ramki...@hotmail.com wrote: > Example/Test Code:

[go-nuts] Re: Wait before Add

2023-01-17 Thread Brian Candler
You're supposed to do Add(1) -> Wait; and you'd normally wait once, in a single goroutine. Typical pattern: wg.Add(1) go func() { defer wg.Done() ... foo } wg.Add(1) go func() { defer wg.Done() ... bar } wg.Wait() // wait for both goroutines to complete On Tuesday, 17 January

[go-nuts] Re: Guaranteeing deterministic execution of Golang code

2023-01-16 Thread Brian Candler
Are you trying to find a pure functional subset of go? In a "pure function", the return value(s) are calculated only from the arguments. The result is not affected by the state of the system, and the state of the system is not affected by the function. That means you can't even do a print()

[go-nuts] Re: etcd, how to stop it ?

2023-01-16 Thread Brian Candler
The homepage for etcd is here: https://etcd.io/ and there is a button labelled "Community". You may also find this page useful: http://www.catb.org/~esr/faqs/smart-questions.html#intro On Sunday, 15 January 2023 at 18:30:09 UTC alex-coder wrote: > Hi All ! > > I do understand that my

Re: [go-nuts] Help Bootstrapping to ESXi

2023-01-14 Thread Brian Candler
P.S. For using tinygo to generate Linux executables, see: https://tinygo.org/getting-started/install/linux/ https://tinygo.org/docs/guides/linux/ But I couldn't find the minimum kernel version requirements. On Saturday, 14 January 2023 at 11:41:21 UTC Brian Candler wrote: > On Friday,

Re: [go-nuts] Help Bootstrapping to ESXi

2023-01-14 Thread Brian Candler
On Friday, 13 January 2023 at 20:42:28 UTC mi...@newclarity.net wrote: I SSHed into the ESXi server, used wget to pull down the Golang tarball, used tar to extract it from within the ESXi shell, and then used `go run hello.go` in the ESXi shell and got a runtime error of "epollwait on fd 4

[go-nuts] Re: shadowing of types by variables

2023-01-13 Thread Brian Candler
The rationale, I understand, is that it helps with the Go compatibility promise: when new types / constants / functions are added to the language, they don't break existing code. On Friday, 13 January 2023 at 10:22:46 UTC paurea wrote: > These programs compile and work according to my reading

[go-nuts] Re: Debugging memory leak when a GO process crashed

2023-01-12 Thread Brian Candler
I think you're not being clear on your problem you're trying to solve. There are no "memory leaks" in Go in the traditional sense (omitting to free an allocation) because of the garbage collector. Therefore, if memory is not being freed in a pure Go program, it's because you are keeping a

[go-nuts] Re: Help Bootstrapping to ESXi

2023-01-10 Thread Brian Candler
"Bootstrapping go" means "building the go compiler toolchain from scratch". You almost certainly don't want to do this. This is something you'd normally only attempt if there is not a suitable go binary distribution available for your system. Go needs to run under an operating system. ESXi

[go-nuts] Re: How to test code using windows when syscalls are involved?

2023-01-05 Thread Brian Candler
https://pkg.go.dev/go/build#hdr-Build_Constraints On Thursday, 5 January 2023 at 15:36:16 UTC uppe...@gmail.com wrote: > many of my colleges are working on Windows, they fail to run `go test` > commands due to syscalls: our projects are heavily using syscalls, their > existences make it

[go-nuts] Re: error not found on add new package to pkg.go.dev

2023-01-05 Thread Brian Candler
https://pkg.go.dev/github.com/GoFarsi/paygap [note capitalization] On Thursday, 5 January 2023 at 15:36:16 UTC ja...@live.com wrote: > hi > > I want add new package to pkg.go.dev, I got error not found and check any > things but not find why i got error. > >

Re: [go-nuts] Remove digits from string

2022-12-30 Thread Brian Candler
https://go.dev/play/p/WxKPohZhbrE On Thursday, 29 December 2022 at 22:12:47 UTC peterGo wrote: > https://go.dev/play/p/F6gNFWjRzGO > > > On Thursday, December 29, 2022 at 12:50:34 PM UTC-5 Mitul sharma wrote: > >> Hello, >> >> I'm stuck in below code snippet, looking to have a output as string

[go-nuts] Re: js.ValueOf for an error

2022-12-23 Thread Brian Candler
I don't know how a raw Go interface value would be usable in Javascript. As an alternative, would it be any good to use sprintf("%T", readErr) as the code, and readErr.Error() as the value? At least those are both strings. https://go.dev/play/p/nd1FXUvD_zg On Friday, 23 December 2022 at

[go-nuts] Re: Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Brian Candler
It depends entirely on your application, and how the various goroutines are wired together with channels. But as a guiding principle: I'd say that anything which *sends* on a channel should close it when it's finished - whether that be due to context cancellation, or some other reason.

[go-nuts] Re: Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Brian Candler
On Monday, 19 December 2022 at 12:01:39 UTC Torsten Bronger wrote: > But would you agree that additional checking is necessary if > DoSomething does not have a ctx argument? > Given that you're running DoSomething synchronously, it will always run to completion. So you'll always have a valid

[go-nuts] Re: Context cancellation: Is it sufficient to make long-running things interruptible?

2022-12-19 Thread Brian Candler
On Monday, 19 December 2022 at 10:01:41 UTC Torsten Bronger wrote: > I would additionally check for ctx.Err() != nil somewhere in the > loop. Or is there a reason why this is not necessary? > See https://pkg.go.dev/context#Context // If Done is not yet closed, Err returns nil. // If

Re: [go-nuts] Linting

2022-12-13 Thread Brian Candler
I'd say that in an entire programming language and runtime environment like Go, there is much which is inherently complex. Just think about things like garbage collection and asynchronous preemption. A linter which creates dumb metrics like "number of

[go-nuts] Re: Hide Golang Code from Exported package

2022-12-12 Thread Brian Candler
Distribute your library as a grpc server. https://github.com/hashicorp/go-plugin On Monday, 12 December 2022 at 07:56:52 UTC nsing...@gmail.com wrote: > Actually i need to share it as an sdk. So any way i can share > > On Thursday, December 8, 2022 at 1:13:17 PM UTC+5:30 marc...@gmail.com >

Re: [go-nuts] Linting

2022-12-10 Thread Brian Candler
The question remains, which linter(s) are you using? -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this

Re: [go-nuts] where is GOROOT set?

2022-12-10 Thread Brian Candler
On Saturday, 10 December 2022 at 05:50:53 UTC pat2...@gmail.com wrote: > thanks, and the playground is nice. > > I think this is saying that if I want a baz and bar executable (chmod +x) > then I need the "package main" in separate folders/directories > Yes. The approach I use (which I borrowed

Re: [go-nuts] Linting

2022-12-10 Thread Brian Candler
On Friday, 9 December 2022 at 19:09:34 UTC Ian Lance Taylor wrote: > 1) Linters are optional and opinionated, and it kind of matters which > linter you mean. And of course, go itself already comes with the grandaddy of all linters - "go vet ". -- You received

Re: [go-nuts] where is GOROOT set?

2022-12-09 Thread Brian Candler
Plus, you don't need to do a "go mod init" in each subdirectory. The top-level directory names the module and the package within it; you can refer to packages in subdirectories using this module name with the subdirectory appended. A typical layout would look like this: (top level) go mod

Re: [go-nuts] Re: Interfaces for nested types with common structure

2022-12-08 Thread Brian Candler
baz.GetBar().GetFoo().Get() } On Wednesday, 7 December 2022 at 18:51:19 UTC dple...@google.com wrote: > On Wed, Dec 7, 2022 at 4:39 AM Brian Candler wrote: > >> On Tuesday, 6 December 2022 at 21:05:48 UTC dple...@google.com wrote: >> >>> I am trying to figure out if there's a

[go-nuts] Re: [DSP] butterworth 4th order High-pass filter requests

2022-12-07 Thread Brian Candler
http://www.catb.org/~esr/faqs/smart-questions.html#homework On Wednesday, 7 December 2022 at 18:09:31 UTC seokta...@gmail.com wrote: > Hi guys, > > I've been diving into GOLANG less than 1 month. > Now I am looking for the DSP filter for butterworth 4th order High-pass > filter for study. > > I

Re: [go-nuts] Re: Why not tuples?

2022-12-07 Thread Brian Candler
On Tuesday, 6 December 2022 at 22:27:38 UTC dple...@google.com wrote: > It'd be great if, for example, you could tag an entire type like: > > type Row struct { `json:tuple` > date int64 > score float64 > city string > } > > so that > > var v []Row > json.Unmarshal(data, ) > > would

[go-nuts] Re: Interfaces for nested types with common structure

2022-12-07 Thread Brian Candler
On Tuesday, 6 December 2022 at 21:05:48 UTC dple...@google.com wrote: > I am trying to figure out if there's a good way to build a helper that can > be used against different sets of nested types that have a common structure. > > So, for example, say there are two libraries, `lib1` and `lib2`

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

2022-12-05 Thread Brian Candler
On Monday, 5 December 2022 at 13:12:26 UTC loji...@gmail.com wrote: > The problem as I see it, is that when the security of the code relies on a > package is outside the main program/executable, it can open potential > problems of code injection; code changes or forks or if the url has moved,

[go-nuts] Re: Issue with regular expression processing

2022-12-05 Thread Brian Candler
For the documentation of the RE2 regular expression dialect, see https://github.com/google/re2/wiki/Syntax ^ matches only at start of string, unless you set multi-line mode: https://go.dev/play/p/GCglWdjqEHq On Monday, 5 December 2022 at 12:10:20 UTC sbezv...@cisco.com wrote: > Hello, > > > >

[go-nuts] Re: Golang Github Package References

2022-12-05 Thread Brian Candler
This question makes no sense to me. If your code actually *uses* "github.com/installed-package" then it will fail to build or run without it. On the other hand, if it doesn't use it, then just remove the import (the compiler will complain about unused imports anyway) I also don't know what

Re: [go-nuts] Re: go install of forked repo

2022-12-05 Thread Brian Candler
Or there is vendoring . On Monday, 5 December 2022 at 09:16:24 UTC stephane@gmail.com wrote: > Hi, > > If you don't want to commit *go.mod*, you can use *go.work > *https://go.dev/ref/mod#go-work-file > > On Monday, December 5, 2022 at

Re: [go-nuts] Performance for concurrent requests

2022-12-03 Thread Brian Candler
Have you tried a tcpdump of the packets between the Go program and nginx? Is it using HTTP/1.1 or HTTP/2? If it's HTTP/1.1, does tcpdump show that it actually starts all 50 HTTP client requests simultaneously? You are making all these concurrent requests to the same host. The default of

[go-nuts] Re: gRPC for web applications with millions of users

2022-12-02 Thread Brian Candler
Just checking that you came across this already? https://grpc.io/blog/state-of-grpc-web/ gRPC can't be implemented natively in browsers. You can sending something gRPC-like and then convert it back to gRPC at the server. But for bi-directional streaming, I think you need to look at Websockets

[go-nuts] Re: What's go's convention for specifying the equivolent of configure --prefix?

2022-12-01 Thread Brian Candler
If you are happy for the compile-time data to be in a file, rather than supplied as flags to the build command, then //go:embed should do the trick. https://pkg.go.dev/embed On Thursday, 1 December 2022 at 09:39:38 UTC hey...@gmail.com wrote: > I'm writing a command line program in go, and it

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-25 Thread Brian Candler
To give a real-world example: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus type metrics struct { cpuTempprometheus.Gauge hdFailures *prometheus.CounterVec } Question: why is prometheus.Gauge not a pointer, but *prometheus.CounterVec is a pointer?

Re: [go-nuts] where is GOROOT set?

2022-11-24 Thread Brian Candler
Your error comes from the spurious import of "treesort" in treesort_test.go. (You are already inside package treesort; there is nothing to import) With this line: $ go test . # example.com/blah treesort_test.go:11:2: package treesort is not in GOROOT (/usr/local/go/src/treesort) FAIL

[go-nuts] Re: How to High-pass filter method for well height data

2022-11-24 Thread Brian Candler
On Wednesday, 23 November 2022 at 19:02:29 UTC seokta...@gmail.com wrote: > I looked for dsp filter through the gitbub, but the bandpass filter was > focused always. > > I don't know this for sure, and you should check with your supervisor if necessary. But I suspect your supervisor was *not*

Re: [go-nuts] where is GOROOT set?

2022-11-24 Thread Brian Candler
On Wednesday, 23 November 2022 at 23:25:51 UTC pat2...@gmail.com wrote: > I've separated my code into separate subdirectories, added a go.mod > ran go mod tidy on each. > > I'm mostly back where I started, which a better source file tree > > I'm trying to test the "treesort" package from the

Re: [go-nuts] where is GOROOT set?

2022-11-21 Thread Brian Candler
On Monday, 21 November 2022 at 04:11:26 UTC pat2...@gmail.com wrote: > > Incidentally, there is no need to have github.com in the directory path >> on your local filesystem. You could just use >> ~/projects/cmd >> > > Doesn't this contradict putting the github path in the name for easy >

Re: [go-nuts] where is GOROOT set?

2022-11-19 Thread Brian Candler
On Saturday, 19 November 2022 at 02:50:18 UTC pat2...@gmail.com wrote: > On Friday, November 18, 2022 at 1:10:40 PM UTC-5 Brian Candler wrote: > >> You still should have a go.mod. Even if you don't intend to publish your >> code anywhere, you give it a module name - anythi

Re: [go-nuts] Module weirdness in playground

2022-11-18 Thread Brian Candler
t 18:29:01 UTC Jan Mercl wrote: > On Fri, Nov 18, 2022 at 7:15 PM Brian Candler wrote: > > > This used to work: > > https://play.golang.org/p/YQoAu1Iwkor > > > > But now when I click on "Run", the import path of " > example.com/myprog/foo" is rem

[go-nuts] Module weirdness in playground

2022-11-18 Thread Brian Candler
This used to work: https://play.golang.org/p/YQoAu1Iwkor But now when I click on "Run", the import path of "example.com/myprog/foo" is removed, and it fails to compile. Any clues as to what's going on? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] where is GOROOT set?

2022-11-18 Thread Brian Candler
> They are just simple go programs that work like perl or python programs, designed to take work with pipes You still should have a go.mod. Even if you don't intend to publish your code anywhere, you give it a module name - anything will do as long as it meets the syntax requirements. See

[go-nuts] Re: WebAssembly and Filesystem access

2022-11-04 Thread Brian Candler
Not sure this is what you're looking for, but Go 1.16 introduced an abstract filesystem interface: https://pkg.go.dev/io/fs https://go.dev/doc/go1.16#fs "the new testing/fstest package provides a TestFS function

[go-nuts] Re: How to run telnet command?

2022-11-02 Thread Brian Candler
I think what you really want is not to use telnet, but to connect to a mailserver on port 25. To establish a TCP connection in Go, you should use net.Dial. See: https://pkg.go.dev/net If you actually want to send mail, there are higher level approaches which will take care of a lot of the

[go-nuts] Re: Trying to create a test app for a library package [solved]

2022-11-02 Thread Brian Candler
> Given that I have a local pkg, mylib, whose module name is github.com/me/mylib, how can I create a local Go application that uses mylib from the local folder it is in rather than actually downloading it from github FYI, what I've just shown doesn't download anything from github. It works

[go-nuts] Re: Trying to create a test app for a library package [solved]

2022-11-02 Thread Brian Candler
>> >> On Wednesday, November 2, 2022 at 9:34:31 AM UTC Mark wrote: >> >>> That doesn't work either (obviously I used my real github a/c name) >>> tester.go:8:2: package github/me/mylib is not in GOROOT >>> >>> On Wednesday, November 2, 2022 at 9:26:35 AM UTC Brian

[go-nuts] Re: Trying to create a test app for a library package

2022-11-02 Thread Brian Candler
In mylib/tester/tester.go: import ( "fmt "github.com/me/mylib" ) On Wednesday, 2 November 2022 at 08:41:24 UTC Mark wrote: > I have this layout: > ``` > mylib/ > mylib/go.mod # module github.com/me/mylib > mylib/mylib.go > mylib/mylib_test.go > ``` > All this works fine, with both .go

Re: [go-nuts] Error Handling Question

2022-10-22 Thread Brian Candler
> And I agree that the above function is much easier to read and much faster to write than the first version! But now I'm raising unchecked exceptions instead of handling errors properly. However you're not "raising an unchecked exception"; you're panicking, which is something different. Go

[go-nuts] Re: How to add zero after a decimal point to float type using decimal lib

2022-10-13 Thread Brian Candler
Please try to give your "requirement" in a more meaningful form. > fmt.Printf("%.2f", value) -> this will do formatting but type is not float which is the requirement. This doesn't mean anything without context. If I write: var value float64 fmt.Printf("%.2f", value) then 'value' clearly

[go-nuts] Re: How to call sort.Search in a loop

2022-10-11 Thread Brian Candler
sort.Search is a binary chop, and needs an ordering condition, >= or <=. If you use == then it cannot work. In addition you're getting a panic here: if ret < len(haystack) { index += ret log.Println("found", index,

[go-nuts] Re: behavior of %f

2022-10-10 Thread Brian Candler
Whilst Go handles constants with arbitrary precision AFAIK, precision is lost once values are assigned to a float64 variable (or passed as an argument to a function). There are only 53 bits of precision in the "mantissa". For more info, you might find this helpful:

[go-nuts] Re: Issue with go-git API

2022-10-10 Thread Brian Candler
Basically, every program now needs a "go.mod" file. Even a "hello world" program should be made like this: mkdir hello cd hello go mod init example.com/hello# this creates "go.mod" vi hello.go # create your program here go run . Whilst it still does work to say "go run hello.go" for a

Re: [go-nuts] Practical use cases of recover in golang

2022-10-10 Thread Brian Candler
On Monday, 10 October 2022 at 06:21:48 UTC+1 Henry wrote: > You may want to make your app more robust by handling panic in the topmost > layer of your application. With many people working on the code and various > external dependencies, it is often impractical to ensure none of the code >

[go-nuts] Re: What is the relationship between go community and goproxy.io

2022-10-10 Thread Brian Candler
> By the go module cache system design, if you trust the server set in your GOSUMDB env var, > which is defaulted to sum.golang.org, then it is not a matter whatever proxy server your are using. >From the point of view of downloaded package integrity, yes. But there are other things an

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

2022-10-05 Thread Brian Candler
On Tuesday, 4 October 2022 at 05:47:49 UTC+1 squadglad...@gmail.com wrote: > We have some disk space restrictions and hence we do not want to include > the common code as a library in the service. That will increase the size of > each exe. We would like to keep the common code and service code

Re: [go-nuts] GO API to upload a directory in the github

2022-10-04 Thread Brian Candler
> undefined: io.Discard What version of Go are you running on your system? io.Discard was introduced in go 1.16 . unsafe.Slice was added in go 1.17 . The most recent version is 1.19, and I'd recommend you use that. On

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

2022-10-03 Thread Brian Candler
On Monday, 3 October 2022 at 10:40:06 UTC+1 squadglad...@gmail.com wrote: > We are trying to use a common code as a DLL which is shared by multiple > services. > You've mixed a problem and solution statement together. You want to share code between multiple services: if so, there are other

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

2022-09-30 Thread Brian Candler
I'm not sure what your threat model is, but I note that if you dump both the encrypted data and the key to the filesystem, then the original secret data is trivially recoverable. And with most filesystems, if you delete a file, the data is still recoverable. I would suggest using an external

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

2022-09-30 Thread Brian Candler
> is go-plugin supported by Windows? If you mean go's own plugin system, then no: https://pkg.go.dev/plugin (sorry, I should have remembered that) If you mean the go-plugin library from Hashicorp: I believe it should be fine. It's used by Hashicorp Vault, and Vault supports Windows:

<    1   2   3   4   5   6   7   8   >