Your answer has put me on the right track. Here's the long
version:
https://stackoverflow.com/questions/48790663/why-value-stored-in-an-interface-is-not-addressable-in-golang
On Wednesday, April 24, 2024 at 6:55:53 PM UTC+2 cpu...@gmail.com wrote:
> > In the first case, the interface co
second case the
> interface contains *S, which is writable, so unmarshal fills it in via
> reflection.
>
> On Wed, Apr 24, 2024 at 10:46 AM cpu...@gmail.com
> wrote:
> >
> > Every time I feel I've come to terms with how Go works I round a corner
> and hit a wall, even
It's worth noting that before the Unmarshal v is {}(main.S) and afterwards
{}(map[string]interface{})
On Wednesday, April 24, 2024 at 6:46:18 PM UTC+2 cpu...@gmail.com wrote:
> Every time I feel I've come to terms with how Go works I round a corner
> and hit a wall, even after
Every time I feel I've come to terms with how Go works I round a corner and
hit a wall, even after doing this for >5 years. Here's one.
Consider this simple code (https://go.dev/play/p/bph5I80vc99):
package main
import (
"encoding/json"
"fmt"
)
type S struct {
Foo int
}
func update(v any) {
label for the hostname (e.g.
> node_exporter, windows_exporter etc).
>
> If there's something special about your situation which means you need to
> do this, can you explain your use case further?
>
> On Wednesday 6 March 2024 at 10:40:29 UTC cpu...@gmail.com wrote:
>
>> T
The Go runtime exposes various metrics. To collect metrics from multiple
servers I'd like to add labels for server name. Is it possible to extend
the build-in metrics for this purpose?
Thanks,
Andi
--
You received this message because you are subscribed to the Google Groups
"golang-nuts"
Yes, CGO is disabled. ldd doesn't seem to exist on MacOS:
make build && ls -la ./evcc && otool -L ./evcc
1.21.7
CGO_ENABLED=0 go build -v -tags=release -trimpath -ldflags='-X
github.com/evcc-io/evcc/server.Version=0.124.1 -X
github.com/evcc-io/evcc/server.Commit=596071b42 -s -w'
-rwxr-xr-x 1
Just gave it another try cross-compiling to Arm on Linux. This time binary
size stays the same. Sorry if my excitement was too premature.
On Friday, February 9, 2024 at 2:11:25 PM UTC+1 cpu...@gmail.com wrote:
> It's really surprising (positively). Compiling with -ldflags='-s -w' if
>
y size.
> However, from 93MB to 81MB, I think it is most likely the result of the
> joint efforts of many CLs.
>
> On Friday, February 9, 2024 at 7:46:48 PM UTC+8 cpu...@gmail.com wrote:
>
>> I was surprised to see my application (MacOS binary) go from 93MB to 81MB
>&
I was surprised to see my application (MacOS binary) go from 93MB to 81MB
(no PGO). Release notes don't mention this.
Has anyone made similar experience or knows why that is?
Thanks,
Andi
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To
Seems it's not possible to create a logger using the log.Logger format in a
straight-forward way?
On Thursday, July 20, 2023 at 3:48:49 PM UTC+2 cpu...@gmail.com wrote:
> The log/slog logger uses the log.Logger format by default. Implementation
> is internal.
>
> In a gradual sw
The log/slog logger uses the log.Logger format by default. Implementation
is internal.
In a gradual switch to slog I'd like to keep that format for time being but
customize other handler options- hence need to create a new Logger. Is
there a good way to do that without reimplementing the
I've recently stumbled across code like this
https://go.dev/play/p/u3UER2ywRlr:
type clientContextKey struct{}
ctx := context.Background()
ctx = context.WithValue(ctx, clientContextKey{}, "foo")
_, ok := ctx.Value(clientContextKey{}).(string)
Naively, I had expected this to fail since I
I have the requirement of being able to drain a channel, i.e. make sure
that downstream processes all data currently being sent. One possible
pattern is something like
for{
select{
case <-q.data:
default:
}
}
where the default branch could indicate that channel has been drained. My
concern
Really strange issue, have been scratching my head for hours now.
Consider
https://github.com/evcc-io/evcc/blob/0b8105d36d245a2169961c48e50fbb830fd38147/charger/ocpp_decorators.go.
Absolutely fine imho. Yet gofmt fails, but only on
CI:
For various reasons we need to patch cryptobytes for our build
(https://github.com/evcc-io/eebus/issues/1#issuecomment-1146843187).
We've tried to do this in a consistent way for local, Docker and Github CI
build by vendoring our modules (go mod vendor) and patching the vendored
copy. Test
Consider https://go.dev/play/p/jgPMwLRRsqe:
errors.As(err, ) will not match if error is of pointer type. As
a result, a library consumer needs to understand if a library returns Error
or *Error. However, that is not part of the API spec as both returns would
satisfy error if Error() is
On Wednesday, June 8, 2022 at 5:53:50 PM UTC+2 Brian Candler wrote:
> On Wednesday, 8 June 2022 at 10:09:26 UTC+1 andig wrote:
>
>> We've not found an approach for communicating with the device sofar
>> unless using patched Go stdlib.
>>
>
> Connect via a proxy like stunnel?
>
> Out of
Sorry to revive this ancient discussion.
We've come
across
https://forum.golangbridge.org/t/x509-certificate-parse-error-with-iot-device/27622/2
where an IOT device from a large vendor uses BER for it's TLS certificate.
It's unlikely, that the vendor will fix the certificate any time soon.
Playing with 1.18 I've noticed that I can immediately replace pretty much
all uses of https://github.com/thoas/go-funk with the new slices package.
One common use case that I happen to have in the codebase quite a lot is
extracting data from a slice of objects:
funk.Map(chargers, func(c
I've developed a semi-complex server application (https://evcc.io) with web
ui. Since web requests are async per nature and I wan't to service them
quickly, mutexes are used. I'm now at the point where I realise that
sprinkling (un)locks over the code quickly leads to deadlocks and
couldn't find
anything regarding enc that should prevent reusing it?
Cheers,
Andi
On Sunday, November 28, 2021 at 9:10:37 PM UTC+1 cpu...@gmail.com wrote:
> I'm trying to transfer arbitrary structs over gRPC. To achieve this I've
> trying to use gob for encoding the interface{} part of the s
I'm trying to transfer arbitrary structs over gRPC. To achieve this I've
trying to use gob for encoding the interface{} part of the structs. The
code looks somewhat like https://go.dev/play/p/4Q5CQE4Wcy2 but not entirely.
Two things strike me strange:
- I receive "gob: decoding into local type
Developing https://github.com/evcc-io/evcc I've recently had a bug report
of unresponsive application. Logfile shows, that the program still has
alive go routines but the main loop doesn't show up in the logs any more,
to it seems stuck.
This may be more a Unix than a Go question: can I
the
errors in a chain.
So I should just use errors.Is here... Sorry for the confusion!
On Monday, August 2, 2021 at 10:02:11 AM UTC+2 cpu...@gmail.com wrote:
> Consider this example: https://play.golang.org/p/16cU0kc8Lku, basically
>
> var Err = errors.New("sentinel")
>
Consider this example: https://play.golang.org/p/16cU0kc8Lku, basically
var Err = errors.New("sentinel")
err := errors.New("foo")
if errors.As(err, ) {
fmt.Println("why?")
}
I'm wondering why this matches the sentinel error, or rather how to
properly use sentinel errors. errors.As says "An
I've recently worked a bit with oauth2 and noticed that issue tracker and
PRs could use a little love. Quite a number of PRs have gone through Gerrit
review without merging and the issues contain some imho valid points.
Is there a policy for maintaining x/oauth2 or putting it into slower
:
> On Sat, 2021-05-15 at 04:47 -0700, cpu...@gmail.com wrote:
> > In my local code, I'm using things like
> >
> > if errors.Is(err, api.ErrMustRetry) { ... }
> >
> > How would I achieve the same on errors returned by the gRCP
> > interface? I've noticed the
In my local code, I'm using things like
if errors.Is(err, api.ErrMustRetry) { ... }
How would I achieve the same on errors returned by the gRCP interface? I've
noticed these are wrapped:
rpc error: code = Unknown desc = must retry rpc error: code = Unknown desc
= must retry
I assume the
There is some support for a configurable token source
in https://github.com/golang/oauth2/pull/448#issuecomment-835811792, no
feedback otherwise.
Cheers,
Andi
On Thursday, April 22, 2021 at 6:10:38 PM UTC+2 cpu...@gmail.com wrote:
> After working with a few more-or-less OAuth2 APIs lately
After working with a few more-or-less OAuth2 APIs lately, I would like to
propose slightly extending the API footprint of the oauth2 library.
By doing so I expect that the amount of userland/provider-specific code can
be reduced- both inside oauth2 and outside in realworld applications. Some
That makes perfect sense as the simple reproducer
shows: https://play.golang.org/p/vSEBtdV2CzR
Only in this case I didn't see it as there were more go routines alive.
Much appreciated, thank you!
On Monday, April 19, 2021 at 11:29:31 PM UTC+2 Brian Candler wrote:
> As far as I understand it:
Hello,
I have a very stupid problem with autocert. The below code works:
log.Println("sslHosts:", sslHosts)
log.Println("sslCertDir:", sslCertDir)
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(strings.Split(sslHosts, " ")...),
Cache:
Consider this layout:
- Repo A contains module foo
- Repo B contains module bar (of course ;)
- Repo B is added as submodule to repo A at /baz
I was expecting that I can
import "foo/baz/bar"
in repo A, but that leads to error ("no required module provides
package...").
Shouldn't
p", ":"+port)
if err != nil {
log.Fatal(err)
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
server := {Addr: ":" + port, Handler: handler}
wg.Done()
log.Fatal(server.Serve(ln))
}()
wg.Wait()
Cheers,
Andi
>
> On Sat, 27 Mar 2021, 14:13 cpu...@gmail.com, wrote:
The typical Go tutorials pattern for starting a server is something like
log.Fatal(http.ListenAndServe(":8080"))
But what if the application needs to do other things after the server is
started? It seems there is virtually no method to wait for the server
actually start listening to
Opened https://github.com/golang/oauth2/issues/487 to propose removing the
`CancelRequest` method.
Cheers,
Andreas
On Friday, March 19, 2021 at 5:44:21 PM UTC+1 cpu...@gmail.com wrote:
> Hi all,
>
> I've recently learned about oauth2 and started to convert some of my
> "manua
On Thursday, March 18, 2021 at 1:53:30 PM UTC+1 ren...@ix.netcom.com wrote:
> One other point on this. Generics will be trivial for 95% of the people -
> they will only need to be able to read and write the instantiation
> statements of type safe collections.
>
> Most developers don’t write
Hi all,
I've recently learned about oauth2 and started to convert some of my
"manual" code using net/http to use an underlying oauth2.Transport for
executing authenticated requests and token refresh.
As a result, my application now sometimes shows
deprecated: golang.org/x/oauth2:
oken (since
> both identifier denote the same type).
>
> But maybe that is not what you are looking for, if that's the case, there
> are other ways around the problem, like type embedding and such.
> Hope this helps,
>
> Le lun. 15 mars 2021 à 13:49, cpu...@gmail.com a
> écri
I've just tried doing something like this in my code:
// Token is an OAuth2 token which includes decoding the expires_in attribute
type Token struct {
oauth2.Token
ExpiresIn int `json:"expires_in"` // expiration time in seconds
}
func (t *Token) UnmarshalJSON(data []byte) error {
...
}
type
[1 + 2 * 3]")
> y := ast2.AnyToAst(x, nil) // wrap the existing AST. does not allocate
> memory.
>
> ythree := y.Get(1).Get(1).Get(1) // extract the "3" as ast2.Node
>
> // now unwrap it, getting the *ast.BasicLit and the Value inside it
> var three s
Good morning.
I've recently found myself writing a code generator for dynamic interface
composition at runtime. It became ugly and I had to pass in quite a number
of parameters that should have been available from reading the source code.
In a second attempt I've reimplemented the generator
Hi Paul!
Thank you for taking the time to reply.
On Friday, September 18, 2020 at 11:33:49 AM UTC+2 Paul Jolly wrote:
> Hi Andi,
>
> > 1) I cannot do go install tools.go:
>
> go install takes main packages as arguments, so no, this will not
> work. The tools.go file (like the example you
Hello experts,
I'm currently using //go:generate with external and module-internal tools.
All external tools are documented in tools.go:
// +build tools
package main
import (
_ "github.com/golang/mock/mockgen"
_ "github.com/mjibson/esc"
)
However, the existing setup has a couple of
ou might
> introduce very hard to find bugs.
>
> On Wed, Aug 26, 2020 at 5:49 PM cpu...@gmail.com wrote:
>
>> Hi All,
>>
>> using interfaces for behavioural testing seems a common pattern in go:
>>
>> if typed, hasCapability := d.(Capability); hasCa
46 matches
Mail list logo