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

2024-03-21 Thread 'Christian Stewart' via golang-nuts
When sending Read() via an RPC call or traversing locks, it is significantly faster to return EOF in the same call as returning the rest of the available data, than to call Read a second time to get the EOF. It's not that hard to handle the EOF semantics. Yes, you have to know what io.EOF means.

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

2024-03-06 Thread 'Christian Stewart' via golang-nuts
On Wed, Mar 6, 2024 at 11:53 AM Jeffery Carr wrote: > On Sunday, March 3, 2024 at 5:46:13 PM UTC-6 Christian Stewart wrote: > Second, you can use "go work" to create a workspace with multiple go > modules in it, so that you can develop with them without having to > constantly update the go.mod

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

2024-03-03 Thread 'Christian Stewart' via golang-nuts
Hi Jeffery, You can build large projects with many repos using Go modules. Firstly, you can reference the other repos and use the latest "master" version by writing "master" where the v verson is in the file, then use "go mod tidy" Second, you can use "go work" to create a workspace with

Re: [go-nuts] Re: How to get net.Conn in rpc function in net/rpc

2023-12-28 Thread 'Christian Stewart' via golang-nuts
I agree with what Brian said and would like to suggest the following two way RPC library with multiplexing over a single connection of any type: https://github.com/aperturerobotics/starpc On Thu, Dec 28, 2023, 10:06 AM 'Brian Candler' via golang-nuts < golang-nuts@googlegroups.com> wrote: >

[go-nuts] Strange redirect behavior with http.StripPrefix

2023-12-19 Thread 'Christian Stewart' via golang-nuts
Hi all, I was very confused by the behavior I was seeing while testing a simple program with http.StripPrefix: package main import ( "fmt" "net/http" ) func main() { mux := http.NewServeMux() mux.HandleFunc("/other/", func(w http.ResponseWriter, r *http.Request) { fmt.Println(r.URL.Path)

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

2023-10-19 Thread 'Christian Stewart' via golang-nuts
Hi, https://pkg.go.dev/golang.org/x/tools/cmd/goimports goimports -w ./ On Thu, Oct 19, 2023, 8:31 PM Pratik Tamgole wrote: > When I use packages, any packages in general, how does the import("fmt") > line correct itself to include the used packages in the program? What tool > is implemented

Re: [go-nuts] Best IDE for GO ?

2023-08-19 Thread 'Christian Stewart' via golang-nuts
Autocomplete and a go language server (gopls) add a ton of speed because you don't need to look up the docs for function and variable names. And go to definition improves speed navigating code significantly. But vim-go can do both, so why not just use it? It's a significant speed increase to

Re: [go-nuts] HTTP client - streaming POST body?

2023-03-22 Thread 'Christian Stewart' via golang-nuts
you can achieve this using an io.Pipe. The io.Pipe function returns a connected pair of *PipeReader and *PipeWriter, where writes to the *PipeWriter are directly read from the *PipeReader. The Write call on the *PipeWriter will block until the data is read from the *PipeReader. pr, pw :=

Re: [go-nuts] HTTP client - streaming POST body?

2023-03-07 Thread 'Christian Stewart' via golang-nuts
No... The previous example streams the file as the post request. The only difference in your example is that you're using stdin. It's not that complicated, files also implement io.reader. On Tue, Mar 7, 2023, 1:41 PM Wojciech Kaczmarek wrote: > Hello, > > I think this code example rather

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
Hi Ian, all, On Wed, Jan 18, 2023 at 6:56 PM Ian Lance Taylor wrote: > > // IsEmpty checks if the interface is equal to nil. > > func IsEmpty[T Block](blk T) bool { > > var empty T > > return empty == blk > > } > > > > (I had blk Block before, instead of blk T). > > > > Comparing with

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
). Comparing with empty is something I've needed to do a bunch of times and have been unable to do. On Wed, Jan 18, 2023 at 5:40 PM Kurtis Rader wrote: > > On Wed, Jan 18, 2023 at 5:14 PM 'Christian Stewart' via golang-nuts > wrote: >> >> The thing I ran into with this t

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
The thing I ran into with this today was, if you want to compare two interfaces: var foo1 Thing var foo2 Thing Ordinarily you can do foo1 == foo2 and it does pointer-wise comparison. But in a generic function, as an example: // IsEmpty checks if the interface is equal to nil. func IsEmpty[T

Re: [go-nuts] Which websockets implementation

2022-12-12 Thread 'Christian Stewart' via golang-nuts
I've been using this one w/o issue and at scale as well; https://github.com/nhooyr/websocket It also supports wasm. On Mon, Dec 12, 2022, 1:22 PM Robert Engels wrote: > I personally like minimal packages like this. Makes them easier to > tailor/debug if something goes wrong. Also simpler to

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

2022-12-04 Thread 'Christian Stewart' via golang-nuts
I definitely fork things and use "replace" quite frequently. When forking something you have to tell Go where to find it, that's what "replace" is for. There's a issue about using replaces in `go install` without a go.mod: https://github.com/golang/go/issues/44840 On Sun, Dec 4, 2022 at 11:40

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

2022-12-02 Thread 'Christian Stewart' via golang-nuts
Hi all, I've built a streaming RPC library compatible with grpc Protobuf service definitions that can do bidirectional streaming to the web browser over any AsyncIterable channel, currently using WebSockets but can also use Message channel to webassembly and other messaging approaches.

Re: [go-nuts] Shellquote in stdlib

2022-11-23 Thread 'Christian Stewart' via golang-nuts
Hi Kurtis, On Wed, Nov 23, 2022, 4:57 PM Kurtis Rader wrote: > On Wed, Nov 23, 2022 at 7:33 AM Christian Stewart > wrote: > >> This is what I'm trying to accomplish: >> >> Start delve (dlv) with os/exec passing a set of []string os.Args as >> --build-flags >> >> Let's say I have this build

Re: [go-nuts] Shellquote in stdlib

2022-11-23 Thread 'Christian Stewart' via golang-nuts
On Sun, Nov 6, 2022 at 9:11 PM Kurtis Rader wrote: > > On Sun, Nov 6, 2022 at 8:48 PM 'Christian Stewart' via golang-nuts > wrote: >> >> There have been several discussions about shellquote in go-nuts in the past: >> >> https://github.com/kballard/go-shellquote &

Re: [go-nuts] Re: Building a Package With Multiple Subdirectories?

2022-11-22 Thread 'Christian Stewart' via golang-nuts
Doesn't it make more sense to fix the cyclic dependencies rather than hack the go compiler and make it do something it wasn't designed to do? Best regards, Christian On Tue, Nov 22, 2022, 4:44 PM jlfo...@berkeley.edu wrote: > The reason I'm asking this question is because, as a learning

[go-nuts] Shellquote in stdlib

2022-11-06 Thread 'Christian Stewart' via golang-nuts
Hi all, There have been several discussions about shellquote in go-nuts in the past: https://github.com/kballard/go-shellquote https://github.com/gonuts/go-shellquote I've found it necessary to use both Split and Join in some cases when working with exec.Command. This seems like the type of

[go-nuts] Re: Parsing comments that don't start with a space

2022-11-06 Thread 'Christian Stewart' via golang-nuts
Hi all, Figured it out: the comments appear in the comment.List, but not comment.Text(): cmap := ast.NewCommentMap(fset, codeFile, codeFile.Comments) for nod, comments := range cmap { for _, comment := range comments { comment.Text() // Does not contain comments w/o a space before

[go-nuts] Parsing comments that don't start with a space

2022-11-06 Thread 'Christian Stewart' via golang-nuts
Hi all, I'm trying to use packages.Load to parse the following comment: // Thing does something. // //my:value do-something I'm trying to parse the my:value comment similar to go:embed. Interestingly the comment does not appear in the AST unless I put a space: // my:value do-something My

Re: [go-nuts] Once again: Include files in go?

2022-11-01 Thread 'Christian Stewart' via golang-nuts
Frank, Am I missing something - can't you just put multiple go files in the same directory? All the go files in the directory will be combined into the same package. This is frequently used for other codegen, like Protobuf. Best, Christian Stewart On Tue, Nov 1, 2022, 7:44 PM Frank Jüdes

Re: [go-nuts] len() is signed ?

2022-10-31 Thread 'Christian Stewart' via golang-nuts
Robert, >From what I've read in the past, unsigned values are generally not used because of the risk of accidental overflow bugs. myLen := len(thing) myLen-- # overflow Best, Christian Stewart On Mon, Oct 31, 2022 at 8:50 PM robert engels wrote: > > In working on some code this night, I kept

[go-nuts] controller-bus: library for dependency injection, dynamic config, hot-loading

2021-08-12 Thread 'Christian Stewart' via golang-nuts
Hi all, I'm writing to share my modular application framework, ControllerBus. https://github.com/aperturerobotics/controllerbus It provides a clean structure for building an application around communicating control loops. If you find this useful and/or have any feedback, feel free to reach