Re: [go-nuts] golan operator

2020-08-02 Thread Kurtis Rader
On Sun, Aug 2, 2020 at 9:56 PM Anjana Prabhakar 
wrote:

> Dear All,
>
> Can someone help me understand the syntax
>
>> a <- b
>> b := <-a
>
>
The "<-" operator is the channel receive operator. See
https://golang.org/ref/spec#Channel_types and
https://golang.org/ref/spec#Receive_operator. Those statements are
retrieving the next value from a channel and assigning it to a variable. I
recommend working through every example at https://tour.golang.org/
. That is the easiest, quickest, way to
gain a basic understanding of the Go language. Your question is addressed
by the concurrency section of the tour:
https://tour.golang.org/concurrency/1.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8FQ2gHW4HJjidWuvO0uBeM4Xv5sL_bMUBLAmc9-uDD%2Bw%40mail.gmail.com.


[go-nuts] golan operator

2020-08-02 Thread Anjana Prabhakar
Dear All,

Can someone help me understand the syntax

> a <- b
> b := <-a

Thanks for the help.

Regards,
Anjana 

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/45924fd8-e099-4461-b2df-db18f426ba7bo%40googlegroups.com.


[go-nuts] Re: Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread ma...@eliasnaur.com


On Sunday, 2 August 2020 at 23:24:20 UTC+2 jake...@gmail.com wrote:

> There is currently no 'clear choice' for GUI in go. It will depend on you 
> needs. Some to look into:
>
> https://bitbucket.org/rj/goey/src/master/
> https://gioui.org/
> https://github.com/andlabs/ui
> https://github.com/goki/gi
> https://github.com/lxn/walk
>

There's also https://fyne.io.

Elias

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/29fb4327-8303-4bed-bf2d-8199a77f2f6en%40googlegroups.com.


[go-nuts] Re: Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread Serge Hulne
Fantastic!

I'll have a great time trying them out!

Thanks!


On Sunday, 2 August 2020 23:24:20 UTC+2, jake...@gmail.com wrote:
>
> There is currently no 'clear choice' for GUI in go. It will depend on you 
> needs. Some to look into:
>
> https://bitbucket.org/rj/goey/src/master/
> https://gioui.org/
> https://github.com/andlabs/ui
> https://github.com/goki/gi
> https://github.com/lxn/walk
>
> On Sunday, August 2, 2020 at 11:53:32 AM UTC-4 Serge Hulne wrote:
>
>> Is there a gui library for Go, like Gtk+ or similar, which will produce a 
>> statically linked executable ?
>>
>> The aim is to create apps which do not require the user to install GTK or 
>> any extra libraries in order to use the app.
>>
>>
>>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ea291b6a-e3ab-497b-9ab1-f78766d5b3dao%40googlegroups.com.


[go-nuts] Re: Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread Serge Hulne
Thanks!

On Sunday, 2 August 2020 23:09:45 UTC+2, smart dev wrote:
>
> Yes, you can use go-astilectron. (electron + go)
> https://github.com/asticode/go-astilectron
>
> On Sunday, August 2, 2020 at 9:53:32 AM UTC-6, Serge Hulne wrote:
>>
>> Is there a gui library for Go, like Gtk+ or similar, which will produce a 
>> statically linked executable ?
>>
>> The aim is to create apps which do not require the user to install GTK or 
>> any extra libraries in order to use the app.
>>
>>
>>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b3d646eb-9ea9-4bd0-a9a7-a6b4bcc912e6o%40googlegroups.com.


[go-nuts] Re: Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread jake...@gmail.com
There is currently no 'clear choice' for GUI in go. It will depend on you 
needs. Some to look into:

https://bitbucket.org/rj/goey/src/master/
https://gioui.org/
https://github.com/andlabs/ui
https://github.com/goki/gi
https://github.com/lxn/walk

On Sunday, August 2, 2020 at 11:53:32 AM UTC-4 Serge Hulne wrote:

> Is there a gui library for Go, like Gtk+ or similar, which will produce a 
> statically linked executable ?
>
> The aim is to create apps which do not require the user to install GTK or 
> any extra libraries in order to use the app.
>
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8963e9bd-5a2a-4f42-9664-6adec0d7d744n%40googlegroups.com.


Re: [go-nuts] Newbie question about type-casts

2020-08-02 Thread Kurtis Rader
In addition to Jake's question regarding whether you want to round up or
down I'll point out there isn't any to cast to float64 and back to int64.
If you want to "round down" just divide by four. If you want to "round up"
add one less than the divisor before dividing; e.g., bet := (cash + 3) /
4. Notice the ":=" which avoids the need for the "var bet int64" statement.

On Sun, Aug 2, 2020 at 2:09 PM Martin Møller Skarbiniks Pedersen <
traxpla...@gmail.com> wrote:

> I have written my first little piece of Go-code.
> However it took some time and code for me to divide a int64 by 4 and round
> down.
>
> How can the last two lines be rewritten?
>
> Regards
> Martin
>
> package main
>
> import (
> "fmt"
> "bufio"
> "math"
> )
>
>
> var cash int64
> scanner := bufio.NewScanner(os.Stdin)
>
> scanner.Scan()
> cash,err = strconv.ParseInt(scanner.Text(), 10, 64)
> if err != nil {
> fmt.Println(err)
> }
>
> var bet int64
> bet = int64(math.Ceil(float64(cash)/float64(4)))
> cash = cash - bet
>
>
>
> --
> 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 golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4aa04075-b8bc-41b1-bbb5-d11403e24763o%40googlegroups.com
> 
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8rr%3Df5C%3DM3c5PueYQKBeT%2B23%2BxJrzxf_-FZyCgep584A%40mail.gmail.com.


[go-nuts] Re: Newbie question about type-casts

2020-08-02 Thread jake...@gmail.com
There is probably a better way, but lets start with a clear definition of 
the problem. Your post says you want to "round *down*" but the variable 
'bet' is the result of a divide by 4, rounded *up*. Which do you actually 
want to do?

On Sunday, August 2, 2020 at 5:09:45 PM UTC-4 traxp...@gmail.com wrote:

> I have written my first little piece of Go-code.
> However it took some time and code for me to divide a int64 by 4 and round 
> down. 
>
> How can the last two lines be rewritten?
>
> Regards
> Martin
>
> package main
>
> import (
> "fmt"
> "bufio"
> "math"
> )
>
>
> var cash int64
> scanner := bufio.NewScanner(os.Stdin)
>
> scanner.Scan()
> cash,err = strconv.ParseInt(scanner.Text(), 10, 64)
> if err != nil {
> fmt.Println(err)
> }
>
> var bet int64
> bet = int64(math.Ceil(float64(cash)/float64(4)))
> cash = cash - bet
>
>
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9858e40e-454e-4700-8556-83f5e3c0ec08n%40googlegroups.com.


[go-nuts] Re: Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread smart dev
Yes, you can use go-astilectron. (electron + go)
https://github.com/asticode/go-astilectron

On Sunday, August 2, 2020 at 9:53:32 AM UTC-6, Serge Hulne wrote:
>
> Is there a gui library for Go, like Gtk+ or similar, which will produce a 
> statically linked executable ?
>
> The aim is to create apps which do not require the user to install GTK or 
> any extra libraries in order to use the app.
>
>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c6b96bc4-4c11-4ada-9d32-674fd99af271o%40googlegroups.com.


[go-nuts] Newbie question about type-casts

2020-08-02 Thread Martin Møller Skarbiniks Pedersen
I have written my first little piece of Go-code.
However it took some time and code for me to divide a int64 by 4 and round 
down. 

How can the last two lines be rewritten?

Regards
Martin

package main

import (
"fmt"
"bufio"
"math"
)


var cash int64
scanner := bufio.NewScanner(os.Stdin)

scanner.Scan()
cash,err = strconv.ParseInt(scanner.Text(), 10, 64)
if err != nil {
fmt.Println(err)
}

var bet int64
bet = int64(math.Ceil(float64(cash)/float64(4)))
cash = cash - bet



-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4aa04075-b8bc-41b1-bbb5-d11403e24763o%40googlegroups.com.


Re: [go-nuts] Type parameters on another line

2020-08-02 Thread Jose Luis Vazquez
Thanks!

I see your point. I guess that is the main reason the type parameters
mapping needs to be in the same declaration line.

Still, for generic types it is ok, but for generic functions it feels a bit
too much stuff crammed into the signature line.

Thanks again for explaining!

Jose

El sáb., 1 ago. 2020 a las 20:29, Ian Lance Taylor ()
escribió:

> On Sat, Aug 1, 2020 at 10:50 AM josvazg  wrote:
> >
> > Let me know if this or something similar was already proposed and
> rejected for some reason but otherwise...
> >
> > What if instead of trying to cram all into a single line we use a
> previous line before the function or type definition explaining how the
> type parameter aliases are to be interpreted. Like this:
> >
> > ```
> > types T Stringify
> > func Stringify(s []T) (ret []string) {
> >...
> > }
> > ```
> > The prefix line:
> > ```
> > types T Stringify
> > ```
> > Only applies to the next code block.
> >
> > IMHO this is more readable, still easy to parse and does not require to
> overload parenthesis or other punctuation for adding type parameters.
> >
> > Issues with this approach:
> >
> > You need to look at at least two lines to understand an expression fully.
> >
> > Is that such a big deal? I mean when an interface is mentioned you still
> need to check that interface definition to fully get it.
> > Also isn't it worse the mess the cramming together makes?
> > Following conventions like T or T1, T2 and such you usually still "read"
> the expression without the types lines.
> >
> > A new keyword `types` is required.
> >
> > Is it ambiguous vs `type`? We could use another name, but this actually
> mean `typeParams` or `typeAliases`... usually keywords are single words
> without camel-case.
> > Again, is it such a big deal compared to the alternative?
> >
> >
> > ## Sample translated original proposal samples
> >
> > This:
> > ```
> > func Print2Same(type T)(s1 []T, s2 []T) { ... }
> > ```
> >
> > Becomes:
> > ```
> > types T
> > func Print2Same(s1 []T, s2 []T) { ... }
> > ```
> >
> > And so on:
> > ```
> > types S Stringer, P Plusser
> > func ConcatTo(s []S, p []P) []string {
> > ...
> > }
> > ```
> >
> > ```
> > types L interface{}, T Stringer
> > func StrAndPrint(labels []L, vals []T) {
> > ...
> > }
> > ```
> >
> > ```
> > // Stringify2 converts two slices of different types to strings,
> > // and returns the concatenation of all the strings.
> > types T1, T2 Stringer
> > func Stringify2(s1 []T1, s2 []T2) string {
> > ```
> >
> > ```
> > // Vector is a name for a slice of any element type.
> > types T
> > type Vector []T
> > ```
> >
> > ```
> > // List is a linked list of values of type T.
> > types T
> > type List struct {
> > ```
>
>
> Your examples don't seem to show any uses of generic types or functions.
>
> I think it's a nice feature of the current design draft that the
> syntax used to declare a generic type or function is very similar to
> the syntax used to use a generic type or function.  The declaration is
> List(type T), and the use is List(int).
>
> Ian
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAN_%3DhD54c7Dza5EWC%3DtOYqdvxnyn1zG2BSdCnb9EFfr_nvEMjg%40mail.gmail.com.


[go-nuts] Is there a gui library for Go, like Gtk+ or similar, which can be used to build statically linked executables ?

2020-08-02 Thread Serge Hulne
Is there a gui library for Go, like Gtk+ or similar, which will produce a 
statically linked executable ?

The aim is to create apps which do not require the user to install GTK or 
any extra libraries in order to use the app.


-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0b52abab-7359-4e51-bd7e-19d46dbf48cco%40googlegroups.com.


Re: [go-nuts] Re: Why we don't have simple throws error statement

2020-08-02 Thread Denis Cheremisov
There are two major issues with Go error handling:


   1. It is not strict enough, i.e. the compiler cannot ensure error check
   2. It is not consistent enough.

In the first you can easily ignore an error and the compiler will let you 
go further. In the second, you can both

*if err := doSomething(); err != nil {*
*}*

and

*v, err := returnSomething()*
*if err != nil {*
*}*

*or err* would do this better for sure

*doSomething() or err {*
*}*

and

*v := returnSomething() or err {*
*}*

воскресенье, 2 августа 2020 г. в 03:55:59 UTC+3, skinne...@gmail.com: 

> I do not consider error handling an issue but then again I tend to either 
> use the Doit() err{} or MustDoit(){} panic and then use  DI (dependency 
> injection implemented by interface) for error-handling so that I can get an 
> email when we get a new error. So then it would be 
> MustDoit(errorHandler("ConIo")){} 
>
> Actually I suppose it is an issue, I do not do error handling in Go, but 
> my preprocessor converts it to Go. Go error handling can do anything, the 
> implementation may not be clear and that may be the real problem. We can 
> change it by improving the language or by training programmers on 
> recognizing useful abstractions, may need both.
>
>
> On Saturday, August 1, 2020 at 1:31:54 PM UTC-5 Ian Lance Taylor wrote:
>
>> On Sat, Aug 1, 2020 at 10:59 AM  wrote: 
>> > 
>> > Has anyone ever tallied the number of different forum threads related 
>> to changing Go error handling ? 
>> > The current method is obviously a vexing issue to many Go users, and 
>> > It seems silly that this issue has never been resolved by the Go team 
>> beyond maintaining the status quo... despite, IMHO, several good 
>> alternatives that have been suggested on this very forum. 
>>
>> There have been many alternatives suggested, but none of them have 
>> been clearly better. 
>>
>> I recently wrote a brief overview at https://golang.org/issue/40432. 
>>
>> Ian 
>>
>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7973c178-cd2c-49cd-b995-4e245f91822cn%40googlegroups.com.