On Sunday, October 28, 2018 at 5:11:49 AM UTC-4, Jan Mercl wrote:
>
> On Sun, Oct 28, 2018 at 2:16 AM T L <[email protected] <javascript:>>
> wrote:
>
> > For example, for a constant string with name Version, you can assure it
> is not blank by using
> >
> > var _ = map[bool]int{false: 0, Version != "": 1}
>
> Too complicated.
>
> const (
> Version = "v1.11"
> _ = 1 / len(Version)
> )
>
> --
>
> -j
>
The *var _ = map[bool]int{false: 0, contidion: 1}* way is more general, it
can be used to assert any conditions.
For OP's request, there are more ways, for example
type _ [len(Version)-1]int
But I admit the way shown by Jan Merci is the cleanest one. Cool!
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.