Hi Max,
this makes the config even simpler since i do not need to be sure that the
field is nil.
I will try this out for sure.
On Wednesday, May 29, 2019 at 1:56:14 PM UTC+3, Max wrote:
>
> There is another improvement you can do: you are currently using
>
> cfg := Config{Name: }
> r :=
There is another improvement you can do: you are currently using
cfg := Config{Name: }
r := reflect.ValueOf(cfg)
which means that 'r' will contain a copy of 'cfg' and will not be settable.
If instead you use:
r := reflect.ValueOf().Elem()
then r will contain a *pointer* to the original 'cfg'
Ok, found it. I should have used the reflect.ValueOf...
On Wednesday, May 29, 2019 at 12:53:13 PM UTC+3, Sotirios Mantziaris wrote:
>
> I did found out that the setter method has to accept a pointer to string.
> I have a complete example now which unfortunately don't work correclty.
> The value
I did found out that the setter method has to accept a pointer to string.
I have a complete example now which unfortunately don't work correclty. The
value should change but it is emptied out.
https://play.golang.org/p/OPZKltApEhF
What am i missing?
On Wednesday, May 29, 2019 at 10:46:32 AM
you are a live saver. thanks very much.
reflection is of of these things in any language i suppose.
On Wed, 29 May 2019 at 10:46, Jan Mercl <0xj...@gmail.com> wrote:
> On Wed, May 29, 2019 at 9:42 AM Sotirios Mantziaris
> wrote:
>
> > I am getting the nested "Name" struct but there are no
On Wed, May 29, 2019 at 9:42 AM Sotirios Mantziaris
wrote:
> I am getting the nested "Name" struct but there are no methods to call.
> What am i doing wrong (besides using reflection :))?
The method has a pointer receiver: https://play.golang.org/p/qjhqSvhE9PL
--
You received this message
Hi,
i have a nested struct and i want to call a method on a field.
type String struct {
value string
}
func (s *String) Set(value string) {
s.value = value
}
type Config struct {
Name String
}
I am getting the nested "Name" struct but there are no methods to call.
What am i doing wrong