[go-nuts] Re: YAML Unmarshal changes keys

2022-04-10 Thread Sam Hughes
I skipped over to that package, and the doc says it converts from yaml to json, and the marshals/unmarshals. I tried changing your snippet to use struct tags with the key name as "json" instead of "yaml", and it immediately behaved as expected: https://goplay.tools/snippet/PSZtr1YErD8 While

[go-nuts] YAML Unmarshal changes keys

2022-04-10 Thread vika...@gmail.com
I am new to GoLang and looking to join two keys (rules) from two different Yamls. I have been able to join the keys but I found that Unmarshal changes the keys (example apiVersion to APIVersion, and kind to Kind). Overall, my goal is to have a valid Kubernetes YAML manifest. This is what I

[go-nuts] Re: Why is Go fun?

2022-04-10 Thread ben...@gmail.com
Reading the spec probably isn't the best way to experience the "fun" in any case. (Though the spec is worth a read once you've use the language a bit -- as far as specs go, it's concise and readable.) "Fun" is quite a personal thing, but similar people often have similar experiences, so I'll

Re: [go-nuts] Packages for Accessing .a Archives?

2022-04-10 Thread 'wagner riffel' via golang-nuts
On Sun Apr 10, 2022 at 4:23 AM CEST, jlfo...@berkeley.edu wrote: > Other than what's in the Go distribution, I haven't been able to find any > packages for accessing .a archives. Is there anything else out there? > Google wasn't helpful. > > Cordially, > Jon Forrest > I found these using

[go-nuts] Constant CPU usage on an idle HTTP server from Go 1.17

2022-04-10 Thread Santiago Corredoira
Hi, On Linux, if I compile and run this simple program: package main import ( "fmt" "net/http" "time" ) type x struct{} func (x) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Write([]byte("")) } func main() { sp := { ReadHeaderTimeout: 5 *

Re: [go-nuts] float exactness

2022-04-10 Thread 'wagner riffel' via golang-nuts
On Sat Apr 9, 2022 at 3:56 PM CEST, 'Jack Li' via golang-nuts wrote: > Why literal operation is exact, variable is not? > > fmt.Println(0.1 + 0.2) // 0.3 exactly > fmt.Println(x + y) // 0.30004 > Both aren't exact because floats can't represent 0.3 exactly, they differ because

[go-nuts] Why is Go fun?

2022-04-10 Thread Kamil Ziemian
Hello, I lack a motivation to read Go spec (long story) and I seek few stories along the line "Go is fun", which it is, to motivate myself. Google didn't give me any results, maybe you can tell me few reasons, why Go is fun? I feel that it is fun, but can't tell why. Best, Kamil Ziemian --

Re: [go-nuts] Dynamically loading custom passes with gollvm?

2022-04-10 Thread Balamurugan Marimuthu
Yes, something like that! I basically want to run my custom pass as I compile using 'go build' But looks like llvm-goc doesn't support the -Xclang option *$ go build -gccgoflags="-Xclang -load -Xclang ../passes/FunctionInsertPass.so" cache_main.go#

Re: [go-nuts] Self-referential generics?

2022-04-10 Thread Shawn Smith
Thanks! This seems obvious now just looking at it, but it was stumping me. I might add for someone that may see this later, in the future it *might* not be needed to do it this way, if all you really just want {Int | Float | Rat} as future versions are supposed to let us use methods in such

Re: [go-nuts] Generic arguments in recursive functions

2022-04-10 Thread Ian Lance Taylor
On Sun, Apr 10, 2022, 11:42 AM Aidan Hahn wrote: > Hello Ian, > > I think some of your confusion may be because the function is poorly > named. In some cases the Node generic may store another Node in the generic > Inner field. > In this case I want my preorder traversal to also traverse the

Re: [go-nuts] Generic arguments in recursive functions

2022-04-10 Thread Aidan Hahn
Hello Ian, I think some of your confusion may be because the function is poorly named. In some cases the Node generic may store another Node in the generic Inner field. In this case I want my preorder traversal to also traverse the list in the Inner field. "TreePreTraverse" would be a better

Re: [go-nuts] Self-referential generics?

2022-04-10 Thread 'Axel Wagner' via golang-nuts
You can use type Comparable[T any] interface { Cmp(other T) int } then *big.Int implements `Comparable[*big.Int]` and you can write func cmpSort[T Comparable[T]](x []C) { … } On Sun, Apr 10, 2022 at 7:48 PM Shawn Smith wrote: > // ... imagine some comparison sort algorithm > > func

[go-nuts] Self-referential generics?

2022-04-10 Thread Shawn Smith
// ... imagine some comparison sort algorithm func cmpSort[C Cmpable](x []C) { for i, val := range x { if i == 0 { continue } _ = val.Cmp(x[i-1]) } } // Cmpable should include big.Int, big.Float, big.Rat, by virtue of their Cmp methods. So how do i

Re: [go-nuts] Structured configuration in Go

2022-04-10 Thread Andrew Pillar
> I think there are two big advantages to making your application > consume either plain JSON or YAML configs: > 1. Everyone is familiar with them > 2. You can use a more advanced tool like cue or jsonnet to generate > them I can see why people would prefer JSON, and I think it's fine for storing

Re: [go-nuts] Structured configuration in Go

2022-04-10 Thread Brian Candler
Cue (and jsonnet) come into their own when building large systems built out of multiple components; they can create configs for multiple applications derived from a shared top-level configuration. However, the applications themselves don't have to understand cue or jsonnet, since both those

Re: [go-nuts] Statically Typed Context

2022-04-10 Thread Christian von Kietzell
Hi Adam, thanks for that article. I really like the idea and will try it on one of my next projects. Cheers, Chris On Thu, Apr 07, 2022 at 01:33:49PM -0700, 'Adam Berkan' via golang-nuts wrote: > Khan Academy Engineering Blog Post: >