Re: [go-nuts] What am I missing here? FYI, I'm completely new to golang xD

2018-09-02 Thread Mhd Shulhan
On Mon, 3 Sep 2018, 13:03 'sebastian andersen' via golang-nuts, < golang-nuts@googlegroups.com> wrote: > This code want's me to believe that I have not declared any of the > variables that I am currently trying to declare: > > func deleteRow() { > db, err := sql.Open("mysql", "root@/testshit")

[go-nuts] Re: What am I missing here? FYI, I'm completely new to golang xD

2018-09-02 Thread Volker Dobler
The equal sign = just assigns a new value to a variable which needs to be declared in advance. The := operator does both steps in one: Declare a variable of appropriate type and assign a value. This is called short variabel declaration and it is explained in the Basics part of the Tour of Go. In

[go-nuts] Re: wasm_exec is no error handling.

2018-09-02 Thread Agniva De Sarker
Appears to be an oversight. Will send a CL. On Monday, 3 September 2018 11:33:25 UTC+5:30, Kazuhiro Kubota wrote: > > Hi guys > > I found that wasm_exec.html does not handle error at Codelab in DevFest > tokyo 2018 ( https://tokyo2018.gdgjapan.org/ ). > https://github.com/golang/go/blob/master/mi

Re: [go-nuts] Listen by multiple goroutines via channels

2018-09-02 Thread Anik Hasibul
Can you please provide an example? I am new to golang. From: Mhd Shulhan Sent: Monday, September 3, 2018 12:17:57 PM To: anik3...@gmail.com Cc: golang-nuts Subject: Re: [go-nuts] Listen by multiple goroutines via channels On Mon, 3 Sep 2018, 13:03 , mailto:anik3

Re: [go-nuts] Listen by multiple goroutines via channels

2018-09-02 Thread Mhd Shulhan
On Mon, 3 Sep 2018, 13:03 , wrote: > I have a postgresql notification listener. > > And i have thousands of different goroutines. > > I am waiting to receive a single notification from each goroutine. > > > But only one channel is getting the value. Example: > https://play.golang.org/p/1a4cVLad8d

[go-nuts] wasm_exec is no error handling.

2018-09-02 Thread Kazuhiro Kubota
Hi guys I found that wasm_exec.html does not handle error at Codelab in DevFest tokyo 2018 ( https://tokyo2018.gdgjapan.org/ ). https://github.com/golang/go/blob/master/misc/wasm/wasm_exec.html#L26-L30 Error handling requires .catch(). I think it would be better to have error handling here. --

[go-nuts] Listen by multiple goroutines via channels

2018-09-02 Thread anik33bd
I have a postgresql notification listener. And i have thousands of different goroutines. I am waiting to receive a single notification from each goroutine. But only one channel is getting the value. Example: https://play.golang.org/p/1a4cVLad8db But I am expecting, all user `Receiver()` shou

[go-nuts] What am I missing here? FYI, I'm completely new to golang xD

2018-09-02 Thread 'sebastian andersen' via golang-nuts
This code want's me to believe that I have not declared any of the variables that I am currently trying to declare: func deleteRow() { db, err := sql.Open("mysql", "root@/testshit") checkErr(err) // delete stmt, err = db.Prepare("delete from userinfo where uid=?") checkErr(er

Re: [go-nuts] Re: How to setup your development environment using Go modules

2018-09-02 Thread Jim
I would suggest that developers get used to using one or more separate branch for releases. Periodically, master will be merged into these branches as part of the release process. It's likely that the source for your package (including go.mod) won't be the only thing that's different between th

[go-nuts] named go routines?

2018-09-02 Thread Robert Engels
Hi, I recently started developing more complex concurrent Go applications. Using the debugger is very difficult - since when looking for a particular routine, the list only shows the top level method - which is usually a runtime park. Couldn't we have a syntax like: go name_exp fun() {...}()

Re: [go-nuts] Re: How to setup your development environment using Go modules

2018-09-02 Thread Mirko Friedenhagen
Publishing to the local cache is how Maven, a build tool for Java, does it. There is the concept of snapshot versions. For Golang maybe stating master (or any other branch) as version would be fitting. Then your CI could use a master checkout as well. Regards Mirko -- You received this messag

[go-nuts] Re: Link: Getting specific about generics

2018-09-02 Thread Robert Engels
I do like using interfaces only, and having the language declare some built-in ones and automatically map them to the operators. A problem is that for consistency they should go both ways... and then you end up with operator overloading which I've never been a fan of because people use it to wr

[go-nuts] Deep Dive Architecture of Book on GoLang

2018-09-02 Thread saurabh bhatia
Hi All, Does anyone knows and wants to recommend the book in GoLand which includes the architecture as well as the though process behind GoLang which may contains concepts in details such as compilers , memory management , interaction with OS etc. Any leads would be highly appreciated. Regards,

[go-nuts] Working or Not

2018-09-02 Thread nvcnvn
Hi, Your blok of code will not work and throw error on COMPILE time. It will not RUN at all. (Do you have Javascript or PHP or similar background? I know some scripting language will allow you to put whatever the identifier in your code and check them on RUNTIME). -- You received this message b

[go-nuts] Re: Working or Not

2018-09-02 Thread Dave Cheney
Hi John Unless the variables a1, a2, a3, b1, ... are defined in the same package as your showBoard function, ie var a1, a2, a3 int then Go will report that they are undefined. Unlike some other languages, Go does not implicitly define a variable on first occurance. All variables must be defin

[go-nuts] Working or Not

2018-09-02 Thread John
I am currently making a program with variables, but when I tried to run it says that the variables are not defined. So below are may code for using the variable: func showBoard() { fmt.Println(" 1 2 3") fmt.Println("a", a1, a2, a3) fmt.Println("b", b1, b2, b3) fmt.Println("

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Dan Kortschak
This is not much different. I is the same as const c = 0.3 - 0.1*3 func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3) for i := 0; i < b.N; i++ { z = c } } On Sun, 2018-09-02 at 20:25 -0700, José Colón wrote: > Yeah, after posting I realized that the compiler wo

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
Yeah, after posting I realized that the compiler would probably be smart enough to optimize that out, so I changed them to: func BenchmarkUntypedConstants(b *testing.B) { var z float64 for i := 0; i < b.N; i++ { z = 0.3 - 0.1*3 } b.Log(z) } func BenchmarkDecimalPackage(b *testing.B) { var z *dec

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Liam Breck
Posted your link to the feedback wiki, and to my design-revision draft, which will land on the issue tracker this week. https://golang.org/wiki/Go2ErrorHandlingFeedback https://gist.github.com/networkimprov/c6cb3e2dff18d31840f2ef22e79d4a1e On Sun, Sep 2, 2018, 4:49 PM Vlad Didenko wrote: > Ab

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Dan Kortschak
This is not a benchmark of the untyped constant expression evaluation. The expression in the loop is performed once and thrown away *at compile time*. The benchmark here is really: func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3) for i := 0; i < b.N; i++ {     } } On Sun,

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
> On Sep 2, 2018, at 3:19 PM, roger peppe wrote: > > > > On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, > wrote: > People may find this excellent paper “Datatype-Generic Programming” by Jeremy > Gibbons useful in this discussion. It’s 72 pages long. > https://www.cs.ox

[go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
Maybe this comparison is completely wrong or unfair, but calculations with Go untyped constants is much faster than the github.com/ericlagergren/decimal package. In the end, they both produce the same correct answer: 0 . func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3)

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Vlad Didenko
Absolutely, go ahead, thank you! I can add more "why" reasoning about "grab" design differences from "catch", but won't get to it until next weekend :( On Sunday, September 2, 2018 at 6:46:08 PM UTC-5, Liam wrote: > > Well, that was then, this is now... > > I'll just note that 10 of 30 feedback

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Liam Breck
Well, that was then, this is now... I'll just note that 10 of 30 feedback posts on the error handling draft feedback wiki have asked for named handlers. Can I add your link there? On Sun, Sep 2, 2018, 4:33 PM Vlad Didenko wrote: > Some time ago, after going through a very similar design (reall

[go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Vlad Didenko
Some time ago, after going through a very similar design (really, even had the catch clause in there), I have arrived at a more generalized version of it. That contemplation (still available at https://didenko.github.io/grab/grab_worth_it_0.1.1.html ) was very much unaccepted here. Well, I act

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 15:54:08 -0700 (PDT) José Colón wrote: > if a package that could provide similar ease of use in performing > infinite precision calculations would be a good idea https://github.com/ericlagergren/decimal It does not fit into stdlibs imo. -- Wojciech S. Czarnecki << ^oo^ >>

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Michael Jones
for money there is a natural limit to the number of digits that are useful, with certain exceptions . add to this the number of digits of fractional p

[go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
This thread is very similar to what you can find if you do a Web search for how to handle financial calculations. From my perspective, and like all matters in programming, the answer is "it depends". It depends on your goals; do you want the highest performance, the highest precision, comply wi

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread roger peppe
On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, wrote: > People may find this excellent paper “Datatype-Generic Programming” by > Jeremy Gibbons useful in this discussion. It’s 72 pages long. > https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf > > I want generics but I still don’t know if I lik

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 20:11:40 +0200 "Wojciech S. Czarnecki" wrote: > error-prone s/error-prone/error-proof/ of course. Though this slip tells me that in fact either way (use ints/use libs) has its error-prone spots. Peace, -- Wojciech S. Czarnecki << ^oo^ >> OHIR-RIPE -- You received this mess

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Michael Jones
Decimal arithmetic is good for money. Decimal fixed point is good for money. Decimal floating point may not be. Dividing 7 pennies by 4 is a good example. 7/4 = 1 3/4, so the 3/4 is accurately expressed in d fractional digits where base^d mod 4 == 0. For base-10 decimal arithmetic, this means two

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 09:58:39 -0700 (PDT) Manlio Perillo wrote: > Then can I assume that all people using the Python decimal module are going > to jail? Not **all**. Only ones using it where either law or mutual agreements mandate fixed point calculations and mandate strict rounding rules (i.e. w

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Manlio Perillo
On Sunday, September 2, 2018 at 5:16:16 PM UTC+2, ohir wrote: > > On Sun, 2 Sep 2018 07:23:55 -0700 (PDT) > Manlio Perillo > wrote: > > > What happens if you need to divide 7 pennies by 4? > > I do not know about pennies peculiarities, so I'll stay with ¤ ;) > > I divide 7µ¤ by 4 then It gi

Re: [go-nuts] Alternate syntax for Go2 generics and contracts

2018-09-02 Thread Scott Cotton
Hi all, I just found out that there is a wiki for this kind of discussion, looks to me like a better venue, more organised, more interest, and just recently proposed on golang.org. Scott On Sunday, 2 September 2018 10:09:43 UTC+2, Tri

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
People may find this excellent paper “Datatype-Generic Programming” by Jeremy Gibbons useful in this discussion. It’s 72 pages long. https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf I want generics but I still don’t know if I like this go2 generics proposal. At least as an exercise i

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 07:23:55 -0700 (PDT) Manlio Perillo wrote: > What happens if you need to divide 7 pennies by 4? I do not know about pennies peculiarities, so I'll stay with ¤ ;) I divide 7µ¤ by 4 then It gives 17500µ¤. On customer account it still is 17500µ¤ but on his statement it print

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Sebastien Binet
Hi, On Sun, Sep 2, 2018, 12:55 haskell_mustard via golang-nuts < golang-nuts@googlegroups.com> wrote: > I prefer seeing the contract by example over having a combination of two > dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), > Ranger, Lener, Caper, ... that have to be m

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Jan Mercl
On Sun, Sep 2, 2018 at 4:24 PM Manlio Perillo wrote: > What happens if you need to divide 7 pennies by 4? > Using integers will result in 1, and this is probably not what you want, if this result needs to be used in further calculations. > > For financial applications you should use decimal float

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Manlio Perillo
What happens if you need to divide 7 pennies by 4? Using integers will result in 1, and this is probably not what you want, if this result needs to be used in further calculations. For financial applications you should use decimal floating-point numbers. Manlio On Thursday, August 30, 2018 at 4

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
The main thing to remember is (from go help modules): > A module is a collection of related Go packages. > Modules are the unit of source code interchange and versioning. Your module import path is github.com/dc0d/farsi. Your module's v2 import path is github.com/dc0d/farsi/v2 etc. Any packages

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
Thanks! Apparently it works now. And I am a bit confused now since version is part of both the path and the version and it has to be imported like "github.com/dc0d/farsi/v2/calendar". But I guess understanding that is my homework - it just feels a bit odd! -- You received this message becaus

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
The v2 of the module needs a /v2 suffix on the module name in go.mod: https://github.com/dc0d/farsi/blob/a31316716e58115e7f7eb987d4e6476aa092cbab/go.mod#L1 You should then be set. On Sun, 2 Sep 2018 at 13:07, Kaveh Shahbazian wrote: > > Sure! > > This is the module that is being imported: https:

[go-nuts] [ANN] Mage 2.3.0 - Now with Go Modules Support

2018-09-02 Thread Nate Finch
Please check it out, and let me know if there are any problems with modules support. https://github.com/magefile/mage https://magefile.org *About Mage* I don't think I've posted here about Mage, so for those that haven't seen it, it's a Make replacement, sort of like Ruby's Rake, except you

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
Sure! This is the module that is being imported: https://github.com/dc0d/farsi And the consumer app: package main import ( "fmt" "github.com/dc0d/farsi/calendar" ) func main() { fmt.Println(calendar.IranNow()) } And its go.mod file: module draft require github.com/dc0d/farsi v0

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
Please can you share details of the project, and/or repro steps? On Sun, 2 Sep 2018 at 12:58, Kaveh Shahbazian wrote: > > A required modules is added to my go.mod file with version v2.0.0 - which I > expect to give me the v2.1.0. > > But after running go mod tidy the version inside go.mod file be

[go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
A required modules is added to my go.mod file with version v2.0.0 - which I expect to give me the v2.1.0. But after running go mod tidy the version inside go.mod file becomes v0.0.0-20180902075018-e96d84f0b065. The project is public on GitHub and has tags v1.0.0, v2.0.0 and v2.1.0. What am I m

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread haskell_mustard via golang-nuts
I prefer seeing the contract by example over having a combination of two dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), Ranger, Lener, Caper, ... that have to be mentally mapped to their actual syntactic representation. This smells like taxonomy ("the lowest form of ac

[go-nuts] Re: Link: Getting specific about generics

2018-09-02 Thread wilk
On 02-09-2018, Tristan Colgate wrote: > --633c2e0574df037c > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > > It's a great read, clarified stuff for me. An approach that embraces > interfaces feels preferable to me. +1 -- William -- You

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Tristan Colgate
It's a great read, clarified stuff for me. An approach that embraces interfaces feels preferable to me. On Sun, 2 Sep 2018, 09:09 'Charlton Trezevant' via golang-nuts, < golang-nuts@googlegroups.com> wrote: > Link: [Getting specific about generics, by Emily Maier]( > https://emilymaier.net/words

Re: [go-nuts] Alternate syntax for Go2 generics and contracts

2018-09-02 Thread Tristan Colgate
Just read: https://emilymaier.net/words/getting-specific-about-generics/ I think I concur, keep specification of behaviour in interfaces if possible. Contracts overlap too much. If interfaces can do the job, all be it less elegantly, the extra verbosity seems worth it to avoid the feature overla

[go-nuts] Link: Getting specific about generics

2018-09-02 Thread 'Charlton Trezevant' via golang-nuts
Link: [Getting specific about generics, by Emily Maier](https://emilymaier.net/words/getting-specific-about-generics/) The interface-based alternative to contracts seems like such a natural fit- It’s simple, straightforward, and pragmatic. I value those aspects of Go’s philosophy and consider t