[go-nuts] [ANN] go-resty v2.2.0 released - Simple HTTP and REST client library

2020-02-23 Thread Jeevanandam M.
Hello All - The package go-resty v2.2.0 released! Stable Version : github.com/go-resty/resty/v2 Release Notes : https://github.com/go-resty/resty/releases/tag/v2.2.0 Cheers, Jeeva -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] Re: [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jan Mercl
Type literals are a prime example of "undefined" types. For example as in `var a []int`. On Sun, Feb 23, 2020, 17:21 Jimu Yang wrote: > Thank you all. > i read all about defined types on the doc > https://golang.org/ref/spec#String_types > now i know many defined types (string bool int ...

[go-nuts] Re: [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jimu Yang
Thank you all. i read all about defined types on the doc https://golang.org/ref/spec#String_types now i know many defined types (string bool int ... but which are the "undefined" types? i didn't find a direct answer. my thinking is that the "literals" which including all type literals

Re: [go-nuts] [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Michael Poole
On Sun, Feb 23, 2020 at 8:19 AM Jimu Yang wrote: > I am reading the doc about Assignability in Golang Specification > . It says: > > A value x is *assignable* to a variable > of type T ("x is assignable to T") >

Re: [go-nuts] [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Ian Lance Taylor
On Sun, Feb 23, 2020 at 5:19 AM Jimu Yang wrote: > > string1's type string and str have identical underlying type (string) and > string is not a defined type. "string" is a defined type. See https://golang.org/ref/spec#String_types. Ian -- You received this message because you are

Re: [go-nuts] [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jan Mercl
Both string1 and str1 have defined types while the quoted specs rule says "at least one of V or T is not a defined type.". On Sun, Feb 23, 2020, 14:19 Jimu Yang wrote: > I am reading the doc about Assignability in Golang Specification > . It says: > >

[go-nuts] [Go Spec]Confused about Assignability in Golang Specification

2020-02-23 Thread Jimu Yang
I am reading the doc about Assignability in Golang Specification . It says: A value x is *assignable* to a variable of type T ("x is assignable to T") if one of the following conditions applies: - ... -

[go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Volker Dobler
It boils down to the meaning of interface{}. interface{} means interface{} and _not_ "any type". While you can assign anything to a variable of type interface{} this does not mean that a variable of type interface{} _is_ "any type". There is no "any type" type in Go. V. On Sunday, 23 February

Re: [go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Glen Huang
This is a great write-up! Going from explaining the terms to applying the terms to the actual problems. I learned a lot. Thanks. On Sunday, February 23, 2020 at 5:37:56 PM UTC+8, Axel Wagner wrote: > > Hi, > > I've wrote about the theoretical side of that here: >

Re: [go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Dan Kortschak
Go is a statically typed language, but the time you get into the case, you must know the concrete type of the v. You allows it to be either map[string]interface{} or map[string]int, this is not a single known type, so the original input type (interface{}) is used. On Sun, 2020-02-23 at 01:24

Re: [go-nuts] keep just 2 decimal places in a float64

2020-02-23 Thread Tom Mitchell
On Sat, Feb 22, 2020 at 1:06 PM 'simon place' via golang-nuts < golang-nuts@googlegroups.com> wrote: > are you sure? > > surely floats can have, say, a small number added, that depending of the > value, sometimes doesn't change them and sometimes does. seems to me the > same issue. > > On

Re: [go-nuts] Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Dan Kortschak
Have a read of https://research.swtch.com/interfaces. There you'll see that the memory layout of int and interface{} are not the same. This means you can't just treat one as the other, which essentially is what you are asking for. On Sun, 2020-02-23 at 01:12 -0800, Glen Huang wrote: > Hi, > > I

Re: [go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread 'Axel Wagner' via golang-nuts
Hi, I've wrote about the theoretical side of that here: https://blog.merovius.de/2018/06/03/why-doesnt-go-have-variance-in.html The post uses slices, but the same arguments apply to maps as well. Specifically, while it *may* seem like you should be able to use a map[string]int as a

[go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Glen Huang
Another slightly related topic: switch v := i.(type) { case map[string]interface{}, map[string]int: fmt.Print(v) } Ideally v is of type map[string]interface{}, but it's interface{} instead. On Sunday, February 23, 2020 at 5:12:27 PM UTC+8, Glen Huang wrote: > > Hi, > > I have a function

[go-nuts] Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Glen Huang
Hi, I have a function that accepts an argument of type map[string]interface{}, and I also have a value of type map[string]int. Currently it seems I can't directly pass the value to the function. Is there anyway I can directly coerce it or a new value of the exact matching type must be