[go-nuts] Licensing terms when using Go code

2018-05-02 Thread Pablo Rozas Larraondo
Hi gophers, I have created a new library reusing some code from the Go standard library. I want to make this project open source and I would like to know if there are requirements in terms of the license for this software. Should I use the same Go BSD license, use BSD without mentioning the Go

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Lucio
E.J. Dijkstra in "A Discipline of Programming" proposed multicase "do" and "if" constructs; the former looping, the latter single-shot. The "guards" he proposed were strictly boolean expressions determining which, if any, of the guarded statements would be executed. If no guard proved true, the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Bakul Shah
On Wed, 02 May 2018 03:04:38 -0700 Lucio wrote: > > E.J. Dijkstra in "A Discipline of Programming" proposed multicase "do" and > "if" constructs; the former looping, the latter single-shot. The "guards" > he proposed were strictly boolean expressions determining which, if

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread 'Axel Wagner' via golang-nuts
On Wed, May 2, 2018 at 11:48 AM Hugh Fisher wrote: > As for not adding any power, that's why I mentioned if-then-else and > switch. > Switch with boolean cases is the same as if then else. It's not an obscure > side effect either, the Go Tour cheerfully explains how to use

AW: [go-nuts] Licensing terms when using Go code

2018-05-02 Thread Lutz Horn
Go is BSD licensed (https://golang.org/LICENSE). This is an easy license: > Copyright (c) 2009 The Go Authors. All rights reserved. > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are met: > > *

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Hugh Fisher
On Tuesday, May 1, 2018 at 10:45:30 PM UTC+10, Ian Lance Taylor wrote: > > > A `while` statement would presumably be exactly identical to a `for` > statement with a single condition. So adding a `while` statement > would not add any power to the language, and would add an additional >

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Louki Sumirniy
for { . } is exactly a while loop. The c style for statement's second clause is exactly this and in c you can do this clumsily with: for (i=1; ; true ) { . } Go assumes that a single boolean expression is the same without initial statement and post block loop statement. If you want to be

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Hugh Fisher
On Tuesday, May 1, 2018 at 11:57:13 PM UTC+10, Michael Jones wrote: > > Maybe he meant "until" aka "do {...} while cond" -- this is a valuable and > missing mechanism. The argument back in the day was that having just one > looping construct was more friendly to tooling. > > No, I meant a

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 11:34 AM Lutz Horn wrote: > You can even write > for true { > } > > to get an infinite loop you will have to break from. for { } works just as well: https://play.golang.org/p/aEkbUjLmf_T -- -j -- You received this message because you are

AW: [go-nuts] Go could really use a while statement

2018-05-02 Thread Lutz Horn
> No, I meant a while { ... } loop for foo > 1 { } is exactly what you are looking for. You can even write for true { } to get an infinite loop you will have to break from. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Louki Sumirniy
It could be effectively added in Go by allowing an optional condition after break statements. -- 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

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 00:26:05 UTC+2, Ian Lance Taylor ha scritto: > > On Tue, May 1, 2018 at 1:28 PM, John Unland > wrote: > > > > So something like x/tools/cmd/assets or cmd/assets? > > Yes. I might use a name more like cmd/embed. > > > > I was just now

[go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
The text Template can accept an arbitrary data: func (t *Template) Execute(wr io.Writer, data interface{}) error What I'm trying to do is to provide a general library that take an arbitrary data just like the text Template does, then add more

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Michael Banzon
I’m guessing that everyone who has a workflow where they currently embed resources in their binary will have specific wishes to how it’ll function. The “easy” way to make serious proposals is to provide an experiment where you demonstrate the change you are proposing with an implementation -

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: > > > > // now > env := make(map[string]string) > for _, e := range os.Environ() { > sep := strings.Index(e, "=") > env[e[0:sep]] = e[sep+1:] > } > // how to add env into data as ENV so that it can be accessed within

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Robert Johnstone
Before there was a wide range of tools for embedding assets, I wrote my own. It is relatively complete, but it did not have a feature to create a debug mode for assets. However, the server took a command-line flag for debug mode, and would access assets through the file system instead of the

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 5:16 PM Tong Sun wrote: Ugly hack, completely wrong in the general case: https://play.golang.org/p/IM_lxT3PxmR -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
Thanks. but, On Wed, May 2, 2018 at 11:27 AM, Burak Serdar wrote: > On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: > > > > > > > > // now > > env := make(map[string]string) > > for _, e := range os.Environ() { > > sep := strings.Index(e, "=") > > env[e[0:sep]] = e[sep+1:] > > } > > //

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 11:47 AM, Burak Serdar wrote: > >> > // now > >> > env := make(map[string]string) > >> > for _, e := range os.Environ() { > >> > sep := strings.Index(e, "=") > >> > env[e[0:sep]] = e[sep+1:] > >> > } > >> > // how to add env into data as ENV so that it can be

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 9:32 AM, Tong Sun wrote: > Thanks. but, > > On Wed, May 2, 2018 at 11:27 AM, Burak Serdar wrote: >> >> On Wed, May 2, 2018 at 9:16 AM, Tong Sun wrote: >> > >> > >> > >> > // now >> > env := make(map[string]string) >> > for _, e := range os.Environ()

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Louki Sumirniy
It adds absolutely nothing, that's why it should not be accepted. It will lead to a divergence in the way it's used as well. However I think maybe run block once before first condition check would be a useful and powerful addition. Maybe it shows my age that I even know what do-while

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 20:02:12 UTC+2, Jan Mercl ha scritto: > > On Wed, May 2, 2018 at 7:39 PM Manlio Perillo > wrote: > > > type Asset interface > > bike shedding: type Assets = http.FileSystem > -- > The interface is different. Open(pkg, path string) ...

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 9:23 PM Manlio Perillo wrote: > Note that you can load assets of any package, not only of the "current" package. No doubt that's useful, but the topic of this thread is about embedded, static assets, fixed at link time. -- -j -- You received

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 20:47:19 UTC+2, Jan Mercl ha scritto: > > On Wed, May 2, 2018 at 8:31 PM Manlio Perillo > wrote: > > > The interface is different. > > > > Open(pkg, path string) ... > > Please explain why the 'pkg' argument is needed. Paths can encode any

Re: [go-nuts] Licensing terms when using Go code

2018-05-02 Thread Ian Lance Taylor
On Wed, May 2, 2018 at 11:46 AM, Pablo Rozas Larraondo wrote: > Thank you Lutz, then, if I understand this right, new projects containing > parts of Go code have to include the original Go BSD license. > > There are a couple of aspects that remain unclear to me: > > -

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 21:53:50 UTC+2, Jan Mercl ha scritto: > > On Wed, May 2, 2018 at 9:23 PM Manlio Perillo > wrote: > > > Note that you can load assets of any package, not only of the "current" > package. > > No doubt that's useful, but the topic of this

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Ian Lance Taylor
On Wed, May 2, 2018 at 5:35 AM, Manlio Perillo wrote: > Il giorno mercoledì 2 maggio 2018 00:26:05 UTC+2, Ian Lance Taylor ha > scritto: > >> Personally I think the code generation approach is simpler. >> > > It is simpler but, isn't it very inefficient with large

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: > > Ugly hack, completely wrong in the general case: https://play.golang.org/ > p/IM_lxT3PxmR > That's it! -- Only three more Replace statements added, but the *big and complicated *problem is overcame. Brilliant. thx a lot. -- You received

[go-nuts] go vet complains about wrong struct?

2018-05-02 Thread Mustafa Arici
Hi, Consider this code. package main var foo = func (){ type A struct {} } type A struct {} func (a A) X() { } func (a A) Y() { a.X() // go vet complains about this method being non-existant } func main() { } When I run go vet, I get: ./main.go:13:2: invalid operation: a

[go-nuts] go tool trace: --> filtering/modifying

2018-05-02 Thread neven . miculinic
High level goal: - I have an application with significant number of goroutine experiencing latency issues. I want to detect and dissect where those issues arise and determine how can I fix them. For that I’ve use go tool trace Middle-level features: - I want to filter

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 19:23:59 UTC+2, Manlio Perillo ha scritto: > > Il giorno mercoledì 2 maggio 2018 17:51:24 UTC+2, Robert Johnstone ha > scritto: >> >> Before there was a wide range of tools for embedding assets, I wrote my >> own. It is relatively complete, but it did not have

Re: [go-nuts] go vet complains about wrong struct?

2018-05-02 Thread Ian Lance Taylor
On Wed, May 2, 2018 at 4:34 AM, Mustafa Arici wrote: > > Consider this code. > > package main > > var foo = func (){ > type A struct {} > } > > type A struct {} > > func (a A) X() { > > } > > func (a A) Y() { > a.X() // go vet complains about this method being

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
Il giorno mercoledì 2 maggio 2018 17:51:24 UTC+2, Robert Johnstone ha scritto: > > Before there was a wide range of tools for embedding assets, I wrote my > own. It is relatively complete, but it did not have a feature to create a > debug mode for assets. However, the server took a

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 8:31 PM Manlio Perillo wrote: > The interface is different. > > Open(pkg, path string) ... Please explain why the 'pkg' argument is needed. Paths can encode any hierarchy. > You also need the package import path to load an asset. I do not

Re: [go-nuts] Licensing terms when using Go code

2018-05-02 Thread Pablo Rozas Larraondo
Thank you Lutz, then, if I understand this right, new projects containing parts of Go code have to include the original Go BSD license. There are a couple of aspects that remain unclear to me: - The copyright notice, list of conditions and disclaimer have to be included in every file of the

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Ian Lance Taylor
On Wed, May 2, 2018 at 2:48 AM, Hugh Fisher wrote: > > On Tuesday, May 1, 2018 at 10:45:30 PM UTC+10, Ian Lance Taylor wrote: >> >> >> A `while` statement would presumably be exactly identical to a `for` >> statement with a single condition. So adding a `while` statement

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Manlio Perillo
On Wed, May 2, 2018 at 6:45 PM, Ian Lance Taylor wrote: > On Wed, May 2, 2018 at 5:35 AM, Manlio Perillo > wrote: >> Il giorno mercoledì 2 maggio 2018 00:26:05 UTC+2, Ian Lance Taylor ha >> scritto: >> >>> Personally I think the code generation

Re: [go-nuts] proposal: embed static assets

2018-05-02 Thread Jan Mercl
On Wed, May 2, 2018 at 7:39 PM Manlio Perillo wrote: > type Asset interface bike shedding: type Assets = http.FileSystem -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Sokolov Yura
for { Body() if !Condition() { break } } It is thats simple, guys. -- 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

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Michael Jones
Ok, weird proposal: Make the per-iteration update part of a for loop change from "assignment to assignment or boolean expression" to allow: *while COND do {...}:* for i:=0; x[i]<4; {...} *do {...} while COND:* for i:= 0; ; x[i]<4 { ...} On Wed, May 2, 2018 at 12:33 PM Louki Sumirniy <

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Dan Kortschak
On weird proposals there's also the `for { } else { }` construct that has been put forward before. On Wed, 2018-05-02 at 21:06 +, Michael Jones wrote: > Ok, weird proposal: Make the per-iteration update part of a for loop > change > from "assignment to assignment or boolean expression" to

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 7:32 PM, Burak Serdar wrote: I think passing in a map is the easiest solution. Agree, however, I'm trying to provide a general library that take arbitrary data just like the text Template does, so imposing this will make my old code broken. If all you need is to pass

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Tong Sun
On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: > > Ugly hack, completely wrong in the general case: https://play.golang.org/ > p/IM_lxT3PxmR > Oh, I now know why it was called "hack", because the thing would get complicated and out of control very easily, e.g., {{add .v1 .v2}} So, still

Re: [go-nuts] How to wrap an arbitrary data with extra data (and then pass to Template)

2018-05-02 Thread Burak Serdar
On Wed, May 2, 2018 at 5:18 PM, Tong Sun wrote: > > > On Wed, May 2, 2018 at 12:06 PM, Jan Mercl wrote: >> >> >> Ugly hack, completely wrong in the general case: >> https://play.golang.org/p/IM_lxT3PxmR > > > Oh, I now know why it was called "hack", because the thing would

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread Michael Jones
but not this... https://play.golang.org/p/cZnSNvi7dNU On Wed, May 2, 2018 at 3:33 PM roger peppe wrote: > On 2 May 2018 at 22:06, Michael Jones wrote: > > Ok, weird proposal: Make the per-iteration update part of a for loop > change > > from

Re: [go-nuts] Go could really use a while statement

2018-05-02 Thread roger peppe
On 2 May 2018 at 22:06, Michael Jones wrote: > Ok, weird proposal: Make the per-iteration update part of a for loop change > from "assignment to assignment or boolean expression" to allow: > > while COND do {...}: > > for i:=0; x[i]<4; {...} > > > do {...} while COND: > >

[go-nuts] Re: Licensing terms when using Go code

2018-05-02 Thread Pablo Rozas Larraondo
Thanks Ian, that is very helpful. I've also googled for reusing BSD software and, as you said, there is plenty of information. On Wednesday, May 2, 2018 at 7:04:34 PM UTC+10, Pablo Rozas Larraondo wrote: > > Hi gophers, > > I have created a new library reusing some code from the Go standard >

[go-nuts] How to change the GBK with golang default charset?

2018-05-02 Thread Able Gao
How to change the GBK with golang default charset? Input and output charset is also GBK. -- 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