Well, reflection is one of the things I love in language and it is a
"must".
On the other hand, the automation is exactly what common libraries do, I
can not find any reason to make a loops if they are repeated actions which
might be implemented in general library. array_intersect is a commo
There is an example: https://go.dev/play/p/guzOWRKi-yp
```
func (c *cachedFn[string, V]) Get0() (V, error) {
// var s any
var s string
s = "abc" // error: cannot use "abc" (untyped string constant) as string
value in assignment
fmt.Printf("cache key: %#v, %T\n", s, s) // cache key: 0, uint8
retur
It's great that we have PGO support in go now, and it's relatively easy to
use. One thing that is of mild concern to me is that typically one will be
checking the default.pgo file in to the repo, and git is notoriously not
great at handling binary blobs that are updated frequently. Its "diff
Yes, this has come up before.
On Fri, Nov 10, 2023 at 7:09 AM ahuigo wrote:
> There is an example: https://go.dev/play/p/guzOWRKi-yp
>
> ```
> func (c *cachedFn[string, V]) Get0() (V, error) {
> // var s any
> var s string
> s = "abc" // error: cannot use "abc" (untyped string constant) as strin
go run command-line-arguments
-X definition
add string value definition of the form importpath.name=value
I used to use this to override my variable values, in the form of
go run -ldflags="-X main.var1=val1 main.var2=val2"
Now, the new problem is that I need to have space in the strin
Hi Adam,
Thanks for sending this, lots of interesting ideas here!
I've been meaning for a long time to have more concrete guidelines for how
much data collection is enough for good results, to include on
https://go.dev/doc/pgo.
I also think it would be valuable to provide tooling that can help m
Hi Vicktoriia,
Go has reflection: https://pkg.go.dev/reflect
And in its various packages it also has many (though not all) of the types
of functions mentioned above that PHP has:
- https://pkg.go.dev/slices & https://pkg.go.dev/golang.org/x/exp/slices
- https://pkg.go.dev/maps & https://
Btw, please ignore the type logic in my code, I wrote this piece of code
just to illustrate the oddities of generics in struct methods.
Regardless of whether its type is int, string, any, *or the exact uint8,
this error is very strange.*
// it doesn't work
func (c *cachedFn[uint8, V]) Get0() (V
Instead of reflect library. I'd like to recommend this generic
library https://github.com/samber/lo.
It's very convenient than reflect, and I've been using it for a long time.
If you are not familiar about how to use it, ask GPT4(GPT3.5 does't know it)
On Friday, June 20, 2014 at 4:47:38 PM UTC+
The uint8 in cachedFn[uint8, V] is the type parameter name, it can be
arbitrary valid identifier.
It shadows the predeclared uint8 identifier.
On Friday, November 10, 2023 at 12:25:05 PM UTC+8 ahuigo wrote:
> Btw, please ignore the type logic in my code, I wrote this piece of code
> just to ill
On Thursday, 9 November 2023 at 18:35:38 UTC+1 Viktoriia Kapyrina
Yelizarova wrote:
] array_intersect is a common example of automation. It makes no sense to
right it again and again as it is common operation which works the same way.
Except that almost all implementations of array_intersect
I agree that it is an unfortunate error message, but to be clear, it is
entirely correct - you are defining a new type called `uint8` and it is
indeed not possible to assign an untyped integer constant to that, as its
underlying type is a type parameter (constrained on any).
I'm pretty sure there
12 matches
Mail list logo