Re: [go-nuts] how to declare type as interface{}

2020-09-03 Thread Harald Weidner
Hello, > but this doesn't work: > > if err := json.NewDecoder(resp.Body).Decode({}{}); err != nil { > t.Fatal(err) > } You can use new(interface{}). See https://play.golang.org/p/s85MwlDygBG Harald -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Assigning byte to string location is not allowed

2020-08-13 Thread Harald Weidner
Hello, > Why is this not allowed? > > s := "hello" > s[0] = 'a' // compile error: cannot assign to s[0] Because strings are immutable in Go. See https://golang.org/ref/spec#String_types You can construct a new string, or convert to byte slive and back.

Re: [go-nuts] Generics and parentheses

2020-07-14 Thread Harald Weidner
Hello, > A typical computer keyboard provides four easily accessible pairs of > single-character symmetrical "brackets": parentheses ( and ), square > brackets [ and ], curly braces { and }, and angle brackets < and >. Go uses > curly braces to delineate code blocks, composite literals, and some

Re: [go-nuts] Re: [generics] some questions

2020-06-18 Thread Harald Weidner
Hello, > But the following code also fails to compile, bug? > > package main > > type Int interface { > type int > } > > func Foo(type T Int) ([]T) {} // undefined: MyInt > > func main() { > type MyInt int > Foo([]MyInt(nil)) > } It compiles if you move "type MyInt int" out of the

Re: [go-nuts] [generics] A Channel of a Generic Structure

2020-06-17 Thread Harald Weidner
Hello, > Here is the playground: https://go2goplay.golang.org/p/CVvUuNJVX-M > I am unable to make this example to compile. This one compiles: https://go2goplay.golang.org/p/2rmaCymukdv Regards, Harald -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Re: [generics] Generic functions calls little confusing to readers

2020-06-17 Thread Harald Weidner
Hello, > There is an existing case which doesn't seem to bother many people: > > foo.Bar() > > Is this calling function Bar in package foo, or method Bar on variable > foo? It could also be a call of a function within the struct value foo. foo.Bar(baz) can have at least four meanings: 1.

Re: [go-nuts] go run requires internet connection?

2020-04-08 Thread Harald Weidner
Hello, On Wed, Apr 08, 2020 at 06:00:19AM -0700, Tanmay Das wrote: > go run helloworld.go > > Strangely the code didn't run. In fact, the terminal prompt never exited. I > kept running the same command over and over again but no luck. You can run "go run -x helloworld.go" to see what the

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Harald Weidner
Hello, > I'm not sure if that is a good idea  > https://play.golang.org/p/Mj77pgsaVsB This is why three-index slices were added in Go 1.2. https://play.golang.org/p/_sJ9OKWsvMz https://golang.org/doc/go1.2#three_index Regards, Harald -- You received this message because you are subscribed

Re: [go-nuts] How many Go compilers are out there?

2019-05-08 Thread Harald Weidner
Hello, On Thu, Apr 25, 2019 at 08:54:57AM -0700, Ian Lance Taylor wrote: > On Thu, Apr 25, 2019 at 8:29 AM JuciÊ Andrade wrote: > > > > These are the ones I am aware of: > > > > . GC toolchain > > . GCC > > . gopherjs > > > > By Go compiler I mean any tool that understands Go source files and >

Re: [go-nuts] undefined and implementation defined behavior in Go

2019-02-19 Thread Harald Weidner
Hello, > I was trying to get a list of undefined and implementation defined > behaviors of the Go language from the specification, but it was not easy. > I tried to search for "undefined behavior" and "implementation defined > behavior" without success. [...] > Is this list complete? The

Re: [go-nuts] Re: do you use binary-only packages?

2018-10-20 Thread Harald Weidner
Hallo, On Fri, Oct 19, 2018 at 11:45:04AM -0700, Ian Lance Taylor wrote: > > Unhelpfully, I imagine it unlikely that anyone distributing binary go > > packages reads golang-dev or golang-nuts. > > Is there a more likely place to reach such people? I believe the best ways to reach attention on

Re: [go-nuts] SQL database connection

2016-09-19 Thread Harald Weidner
Hello, On Mon, Sep 19, 2016 at 01:37:14AM -0700, loc...@gmail.com wrote: > import( > _ "github.com/go-sql-driver" > ) The correct name of this package is: github.com/go-sql-driver/mysql Harald -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] flag: Stack overflow when return stringer with fmt.Sprint

2016-09-01 Thread Harald Weidner
Hello, On Thu, Sep 01, 2016 at 01:59:12AM -0700, Muhammad Shulhan wrote: > > type Slices []string > > > > func (sl *Slices) String() string { > > return fmt.Sprint(sl) > > } > runtime: goroutine stack exceeds 25000-byte limit > fatal error: stack overflow It is always dangerous to

Re: [go-nuts] Re: In case you missed it: language benchmarks for Go 1.7, and language adoption

2016-08-31 Thread Harald Weidner
Hello, On Tue, Aug 30, 2016 at 04:41:29PM -0700, 'Eric Johnson' via golang-nuts wrote: > I looked at the k-nucleotide program, and was unable to figure out a way to > make it faster. > This is, of course, exactly what the test is suppose to be checking - the > speed of the built in map. Anyone