[go-nuts] Re: My views on Go and why it's better than Scripting

2018-03-02 Thread dorival . pedroso
Thanks for your suggestion!

To put it in context, I'm drafting a plan for my colleagues in order to 
make a case for using Go in teaching instead of Fortran or C.



On Friday, March 2, 2018 at 1:29:45 PM UTC-8, dorival...@gmail.com wrote:
>
> Hi, I could be wrong (please correct me ;-), but here you are what I think 
> about Go:
>
> INTRODUCTION
> Computers and software were initially developed for scientific computing; 
> e.g., ALGOL and FORTRAN from the 1950s! Therefore, several computer 
> languages and libraries have been invented and are used in scientific 
> computing to date.  Nonetheless, when programming a new scientific 
> simulation, the question about computational efficiency versus ease-of-use 
> remains open. Here, we aim to shed light on a suitable answer to this 
> question---TL;DR use Go and Gosl!
>
> One would say that scripting (interpreted) languages might provide the 
> convenient platform for computations as long as care is taken to send 
> intensive tasks to functions pre-compiled with high-performance languages. 
> This strategy fails to create an easy-to-use environment because the 
> programmer needs to think when and where those tasks should go. Considering 
> that this kind of decision is essential for performance, we argue that 
> scripting language is not the best solution.  Furthermore, we argue that 
> scripting is the worst tool for teaching new programmers in scientific 
> computing.
>
> We argue that only experts should use scripting languages (scripts) for 
> computer programming because beginners cannot understand how dangerous the 
> flexibility of scripts can be. For example, the assignment of variables 
> with the same name to different types is often a cause of misunderstandings 
> and failures. To make this problem even worse, failures due to wrong types 
> are not captured at runtime---certainly not at compilation time (there is 
> no compilation time in scripts). In other words, the interpreter is too 
> permissive.  The scientist, if aware (rarely the case with students), will 
> investigate the numerical output and, after much work, will find the source 
> of the error. Therefore, this situation is not ideal. To exemplify, the 
> following is allowed in Python (or Julia---similar syntax):
>
> ```
> a = 1.0
> a = "a" # OK in Python or Julia
> ```
>
> In the following code, Go will detect the error with a message such as 
> `./test.go:5: cannot use "a" (type string) as type float64 in assignment`:
>
> ```
> package main
> func main() {
> a := 1.0
> a = "a" // not accepted in Go
> }
> ```
>
> The problem propagates in scripting languages when developing 
> objected-oriented code. For example, a member data of a class can be 
> entirely modified by `anyone`, `anywhere` in Python! This issue completely 
> defeats the purpose of encapsulation in OOP.
>
> In summary, scripting (e.g., Python) and alike (e.g., Julia, Matlab) 
> languages are excellent for the expert programmer only who can understand 
> what is going on. However, they are very misleading to the beginner. In 
> other words, the strictness of compiled languages DOES help to learn 
> computer programming. Furthermore, the tools for working with compiled 
> language often take advantage of well-defined types. The shift towards type 
> declaration is so apparent that new languages and strategies are being 
> invented to overcome these issues. For example, TypeScript and Javascript 
> (ES6) combined with FlowType have been recently developed and have a fast 
> adoption among web developers. It seems that no new large project will use 
> non-typed Javascript code.
>
> GO LANGUAGE
> Go is a modern programming language created by Google engineers in 2007, 
> including Robert Griesemer, Rob Pike, and Ken Thompson. The language was 
> later made public as open source in 2009. Go has since grown exponentially 
> attracting a large number of co-developers and users. The primary goal 
> leading to the introduction of yet a new language was the combination of 
> efficiency (like C/C++) with ease of development (like Python). There are 
> other several innovations and advantages in Go when compared with 
> mainstream languages such as C/C++/C#/Java/Python/Ruby/Lua. 
> Also, Go automatically detects Fortran and C files which helps taking 
> advantage of good existing code.
>
> The vocabulary in Go is quite small compared to other languages, making 
> easy to have an overview of the syntax and available commands. Go avoids 
> complexities such as generics (aka templates) usually available in other 
> languages (e.g., C++). Go also tries to avoid unnecessary complexity by not 
> taking `in the language` advanced OOP concepts such as polymorphism, 
> multiple inheritances, and others. Moreover, Go is somewhat pragmatic in 
> the sense that, if an operation can be made much more straightforward, 
> although slightly orthogonal to the central paradigm, this operation will 
> be carefully defined and adopted in the 

[go-nuts] My views on Go and why it's better than Scripting

2018-03-02 Thread dorival . pedroso
Hi, I could be wrong (please correct me ;-), but here you are what I think 
about Go:

INTRODUCTION
Computers and software were initially developed for scientific computing; 
e.g., ALGOL and FORTRAN from the 1950s! Therefore, several computer 
languages and libraries have been invented and are used in scientific 
computing to date.  Nonetheless, when programming a new scientific 
simulation, the question about computational efficiency versus ease-of-use 
remains open. Here, we aim to shed light on a suitable answer to this 
question---TL;DR use Go and Gosl!

One would say that scripting (interpreted) languages might provide the 
convenient platform for computations as long as care is taken to send 
intensive tasks to functions pre-compiled with high-performance languages. 
This strategy fails to create an easy-to-use environment because the 
programmer needs to think when and where those tasks should go. Considering 
that this kind of decision is essential for performance, we argue that 
scripting language is not the best solution.  Furthermore, we argue that 
scripting is the worst tool for teaching new programmers in scientific 
computing.

We argue that only experts should use scripting languages (scripts) for 
computer programming because beginners cannot understand how dangerous the 
flexibility of scripts can be. For example, the assignment of variables 
with the same name to different types is often a cause of misunderstandings 
and failures. To make this problem even worse, failures due to wrong types 
are not captured at runtime---certainly not at compilation time (there is 
no compilation time in scripts). In other words, the interpreter is too 
permissive.  The scientist, if aware (rarely the case with students), will 
investigate the numerical output and, after much work, will find the source 
of the error. Therefore, this situation is not ideal. To exemplify, the 
following is allowed in Python (or Julia---similar syntax):

```
a = 1.0
a = "a" # OK in Python or Julia
```

In the following code, Go will detect the error with a message such as 
`./test.go:5: cannot use "a" (type string) as type float64 in assignment`:

```
package main
func main() {
a := 1.0
a = "a" // not accepted in Go
}
```

The problem propagates in scripting languages when developing 
objected-oriented code. For example, a member data of a class can be 
entirely modified by `anyone`, `anywhere` in Python! This issue completely 
defeats the purpose of encapsulation in OOP.

In summary, scripting (e.g., Python) and alike (e.g., Julia, Matlab) 
languages are excellent for the expert programmer only who can understand 
what is going on. However, they are very misleading to the beginner. In 
other words, the strictness of compiled languages DOES help to learn 
computer programming. Furthermore, the tools for working with compiled 
language often take advantage of well-defined types. The shift towards type 
declaration is so apparent that new languages and strategies are being 
invented to overcome these issues. For example, TypeScript and Javascript 
(ES6) combined with FlowType have been recently developed and have a fast 
adoption among web developers. It seems that no new large project will use 
non-typed Javascript code.

GO LANGUAGE
Go is a modern programming language created by Google engineers in 2007, 
including Robert Griesemer, Rob Pike, and Ken Thompson. The language was 
later made public as open source in 2009. Go has since grown exponentially 
attracting a large number of co-developers and users. The primary goal 
leading to the introduction of yet a new language was the combination of 
efficiency (like C/C++) with ease of development (like Python). There are 
other several innovations and advantages in Go when compared with 
mainstream languages such as C/C++/C#/Java/Python/Ruby/Lua. 
Also, Go automatically detects Fortran and C files which helps taking 
advantage of good existing code.

The vocabulary in Go is quite small compared to other languages, making 
easy to have an overview of the syntax and available commands. Go avoids 
complexities such as generics (aka templates) usually available in other 
languages (e.g., C++). Go also tries to avoid unnecessary complexity by not 
taking `in the language` advanced OOP concepts such as polymorphism, 
multiple inheritances, and others. Moreover, Go is somewhat pragmatic in 
the sense that, if an operation can be made much more straightforward, 
although slightly orthogonal to the central paradigm, this operation will 
be carefully defined and adopted in the language specification. These 
features, thanks to the unquestionable expertise of the core developers, 
made Go an enjoyable language to work with.

One limitation of some other languages is code organization and package 
development. For example, C/C++ require the use of `#ifndef`, `#define`, 
`#endif`, or `#pragma once` everywhere to prevent code being included more 
than once. In fact, it is 

Re: [go-nuts] General question: complex search form and query params

2018-03-02 Thread benjamin . guy . thomas
Thanks for the feedback.

I'm only vaguely familiar with graphql. From my understanding, it's meant 
to facilitate data query for the frontend dev.

But I'm looking at things more from a user perspective here, see my github 
example.

I might have to dig into this though.

Le vendredi 2 mars 2018 16:15:00 UTC+1, Alex Efros a écrit :
>
> Hi! 
>
> Many years ago I've implemented something similar in Perl, which was later 
> released as https://metacpan.org/pod/DBIx::SecureCGI. Nowadays I suppose 
> best way to do something like this is using GraphQL (for ex. 
> https://github.com/graphql-go/graphql). 
>
> -- 
> WBR, Alex. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: How to limit what the `go get` command is able to import

2018-03-02 Thread paraiso . marc
> Our internal packaging teams biggest worry is that we don't want someone 
to download something to their development laptop, compile the code into a 
standalone binary, then deploy that out to our container platforms.

That's not really a problem with Go but an organizational problem. 

You don't want people to download stuff from the internet? use a firewall 
disallowing people from accessing the internet. Anybody can go on github, 
click on a link and get a zip with some source code. How are you going to 
deal with that? it has nothing to do to with Go. Either you trust your 
developers with their intelligence, or you don't and you don't allow them 
to deploy anything on your container platforms without significant code 
review from an accredited developer who will be the only one authorized to 
deploy anything on your container platforms.


Le vendredi 2 mars 2018 11:59:13 UTC+6, Brendan O'Dwyer a écrit :
>
> Yes(technically) our deploys are controlled via gitlab. 
>
> Our internal packaging teams biggest worry is that we don't want someone 
> to download something to their development laptop, compile the code into a 
> standalone binary, then deploy that out to our container platforms.
>
> In our production environment this isn't even an issue because we can 
> can't even reach out to the internet in builds/deploys because its limited 
> to only internal locations. Their concern is that in development people 
> could `go get` packages that are not approved, then deploy those. While 
> that is super cool and awesome in open source worlds, unfortunately I work 
> for a bank that really likes to restrict and limit things so that they are 
> as secure as can be.
>
> On Wednesday, February 21, 2018 at 4:18:54 PM UTC-6, matthe...@gmail.com 
> wrote:
>>
>> Are the builds and deployment controlled? The command “go list” can be 
>> used to simplify parsing the imports in each package, so a script could 
>> check that every import is either an allowed standard library package or 
>> one matching your internal URL.
>>
>> Matt
>>
>> On Wednesday, February 21, 2018 at 11:37:35 AM UTC-6, Brendan O'Dwyer 
>> wrote:
>>>
>>> My company wants to start using go more, and traditionally when we use 
>>> java and python, when we package them for the developer laptops we override 
>>> settings and configs for the installs to point to our internal Artifactory 
>>> so that we don't have developers using packages that haven't been ok'd for 
>>> use. I was wondering if there was anyway to do this or configure go to 
>>> limit what its allowed to import from the open internet with the `go get` 
>>> command?
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: General question: complex search form and query params

2018-03-02 Thread benjamin . guy . thomas

>
> I believe correctly used database/sql (with the argument placeholders) 
> protects against SQL injection
>

Yeah I badly explained this, an SQL builder solves security *AND* 
flexibility for me. Standard database/sql placeholders are too painful when 
the user params are too complex, and I can't just pass around SQL fragments.

It sounds like you are reinventing SQL. Why do you need a DSL?
>

Yes, in a way SQL would be awesome, but way too powerful (and too verbose). 
You can potentially access data from other tables, update/delete data, etc.

And how could you pass along raw SQL securely?

I guess restricting data access could solve some issues. But let's say I'd 
like to give access to a regex filter for some columns, but not others (for 
performance reasons). Not sure if this would be possible at all via db 
policies.

I guess I'm looking for a "dumbed down" query language.

In other words, as a programmer I've always been frustrated by search forms 
I've developed. As a user, same thing, I always find them too restrictive.

I feel access to a DSL could be interesting for a power user, rather than 
trying to anticipate every combination of search params a user would want 
to perform. 

Look at github for example, their advanced search form is interesting, and 
love how readable the url can 
be: https://github.com/search?q=language:Go+stars:<100+forks:>500

However every params seems to be ANDed, so let's say you'd like to search 
golang repos with less than 100 stars OR forks greater than 500, you can't 
do it.

Also if you pass invalid input, you seem to get garbage 
: /search?q=language:whatever+stars:<100, so I feel that overall the user 
experience is not that great.

You see my point?
 

Le vendredi 2 mars 2018 15:11:19 UTC+1, matthe...@gmail.com a écrit :
>
> To prevent SQL injection and for flexibility, I'm set on using an sql 
>> builder library.
>
>
> I believe correctly used database/sql (with the argument placeholders) 
> protects against SQL injection.
>
> There’s a query builder for postgres with MIT license posted here a few 
> days ago: https://groups.google.com/forum/#!topic/golang-nuts/Mtqvr1N1zAI
>
> Otherwise strings.Builder (or bytes.Buffer pre-1.10), + string 
> concatenation, or fmt.Sprintf can do it.
>
> ## First, create a solid CLI app. Then port it to the web via a JSON API, 
>> that would simply consume the query string.
>
>
> In Go this might be best done as a non-main package with a cmd folder that 
> has a folder for the server and a folder for the CLI app.
>
> I'm thinking of implementing a lexer/parser for this, but first I'd like 
>> to make sure I'm not going to reinvent the wheel :)
>
>
> It sounds like you are reinventing SQL. Why do you need a DSL?
>
> Matt
>
> On Friday, March 2, 2018 at 7:45:19 AM UTC-6, Benjamin Thomas wrote:
>>
>> Hello gophers,
>>
>> Sorry if this is considered noise to some, as I have a question which is 
>> not specifically go related.
>>
>> I have a personal project in which I'd like to use go though.
>>
>> Basically, I'd like to create a complex search form, returning data 
>> backed by an SQL database.
>>
>> To prevent SQL injection and for flexibility, I'm set on using an sql 
>> builder library.
>>
>> However I'm not sure how to go about querying the data itself, via query 
>> params, without creating lots of boiler plate and duplication.
>>
>> I'm wondering if a solution similar to what I'm looking for exists, as 
>> I've never stumbled upon one...
>>  
>> I'm submitting my thoughts below, and would greatly appreciate feedback :)
>>
>> ===NOTES_START===
>> # Idea for query params, for a search form.
>>
>> Upon UI changes, javascript would generate the appropriate final query 
>> string
>>
>> A query string could be typed in by a power user, to handle cases not 
>> covered by a simpler UI (via the url or text input)
>>
>> ## First, create a solid CLI app. Then port it to the web via a JSON API, 
>> that would simply consume the query string.
>>
>> ```
>> go run ./cmd/query/main.go QUERY_STRING
>> ```
>>
>> ## Query string format would follow this principle
>>
>> PARAM_NAME : VALUE : OPERATOR
>>
>> ```
>> # Commands
>> columns:posted_on,short_descr:eq
>> columns:posted_on,short_descr:hide
>> columns:posting_id,posted_on,short_descr:show
>>
>> limit:10:eq
>> limit:10  # would default to `eq`?
>>
>> page:1
>> page:2
>> offset:20
>>
>> # Filtering
>> euros:11.94 # would default to `eq`?
>> euros:11.94:eq
>> euros:100:lt
>> euros:100:lte
>>
>> comment:FIXME # would default to `eq`?
>> comment:FIXME:eq
>> comment:NULL:eq
>> comment:NULL:ne
>> comment:%tickets%:like
>> comment:%Tickets%:ilike
>>
>> payee:Amazon|Google:re # regex
>> payee:AMAZON|Google:rei # regex, case insensitive
>>
>> ```
>>
>> ## Question: how would I chain commands? I cannot use & in urls.
>>
>> ### Maybe with a pipe char
>>
>> QUERY_STRING | QUERY_STRING | QUERY_STRING
>>
>> ### Or via AND, OR keywords
>>
>> ```
>> qs=QUERY_STRING
>>
>> qs AND qs OR qs

[go-nuts] Re: How to limit what the `go get` command is able to import

2018-03-02 Thread matthewjuran
How do you stop people from downloading and deploying arbitrary python or 
java libs?

I can see that more than a developer policy is needed since it takes a 
corrupt employee only one try to break the system before they’re caught, 
and if the employee actually just made a mistake then firing them would be 
worse than not allowing this at all.

In our production environment this isn't even an issue because we can can't 
> even reach out to the internet in builds/deploys because its limited to 
> only internal locations.


It could be if the developer checks the outside package into the vendor 
directory.

Our internal packaging teams biggest worry is that we don't want someone to 
> download something to their development laptop, compile the code into a 
> standalone binary, then deploy that out to our container platforms.


I think you’d have to trust anybody that has this power. Perhaps deployment 
can be limited to only the official build channel?

Matt

On Friday, March 2, 2018 at 9:29:13 AM UTC-6, Brendan O'Dwyer wrote:
>
> Yes(technically) our deploys are controlled via gitlab. 
>
> Our internal packaging teams biggest worry is that we don't want someone 
> to download something to their development laptop, compile the code into a 
> standalone binary, then deploy that out to our container platforms.
>
> In our production environment this isn't even an issue because we can 
> can't even reach out to the internet in builds/deploys because its limited 
> to only internal locations. Their concern is that in development people 
> could `go get` packages that are not approved, then deploy those. While 
> that is super cool and awesome in open source worlds, unfortunately I work 
> for a bank that really likes to restrict and limit things so that they are 
> as secure as can be.
>
> On Wednesday, February 21, 2018 at 4:18:54 PM UTC-6, matthe...@gmail.com 
> wrote:
>>
>> Are the builds and deployment controlled? The command “go list” can be 
>> used to simplify parsing the imports in each package, so a script could 
>> check that every import is either an allowed standard library package or 
>> one matching your internal URL.
>>
>> Matt
>>
>> On Wednesday, February 21, 2018 at 11:37:35 AM UTC-6, Brendan O'Dwyer 
>> wrote:
>>>
>>> My company wants to start using go more, and traditionally when we use 
>>> java and python, when we package them for the developer laptops we override 
>>> settings and configs for the installs to point to our internal Artifactory 
>>> so that we don't have developers using packages that haven't been ok'd for 
>>> use. I was wondering if there was anyway to do this or configure go to 
>>> limit what its allowed to import from the open internet with the `go get` 
>>> command?
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: How to limit what the `go get` command is able to import

2018-03-02 Thread brendan . p . odwyer
Yes(technically) our deploys are controlled via gitlab. 

Our internal packaging teams biggest worry is that we don't want someone to 
download something to their development laptop, compile the code into a 
standalone binary, then deploy that out to our container platforms.

In our production environment this isn't even an issue because we can can't 
even reach out to the internet in builds/deploys because its limited to 
only internal locations. Their concern is that in development people could 
`go get` packages that are not approved, then deploy those. While that is 
super cool and awesome in open source worlds, unfortunately I work for a 
bank that really likes to restrict and limit things so that they are as 
secure as can be.

On Wednesday, February 21, 2018 at 4:18:54 PM UTC-6, matthe...@gmail.com 
wrote:
>
> Are the builds and deployment controlled? The command “go list” can be 
> used to simplify parsing the imports in each package, so a script could 
> check that every import is either an allowed standard library package or 
> one matching your internal URL.
>
> Matt
>
> On Wednesday, February 21, 2018 at 11:37:35 AM UTC-6, Brendan O'Dwyer 
> wrote:
>>
>> My company wants to start using go more, and traditionally when we use 
>> java and python, when we package them for the developer laptops we override 
>> settings and configs for the installs to point to our internal Artifactory 
>> so that we don't have developers using packages that haven't been ok'd for 
>> use. I was wondering if there was anyway to do this or configure go to 
>> limit what its allowed to import from the open internet with the `go get` 
>> command?
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] General question: complex search form and query params

2018-03-02 Thread Lutz Horn

Nowadays I suppose
best way to do something like this is using GraphQL (for ex.
https://github.com/graphql-go/graphql).


But GraphQL != SQL. Building SQL from HTTP query parameters is not made 
more simple and secure by building GraphQL from HTTP query parameters.


Lutz

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] General question: complex search form and query params

2018-03-02 Thread Alex Efros
Hi!

Many years ago I've implemented something similar in Perl, which was later
released as https://metacpan.org/pod/DBIx::SecureCGI. Nowadays I suppose
best way to do something like this is using GraphQL (for ex.
https://github.com/graphql-go/graphql).

-- 
WBR, Alex.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: General question: complex search form and query params

2018-03-02 Thread matthewjuran

>
> To prevent SQL injection and for flexibility, I'm set on using an sql 
> builder library.


I believe correctly used database/sql (with the argument placeholders) 
protects against SQL injection.

There’s a query builder for postgres with MIT license posted here a few 
days ago: https://groups.google.com/forum/#!topic/golang-nuts/Mtqvr1N1zAI

Otherwise strings.Builder (or bytes.Buffer pre-1.10), + string 
concatenation, or fmt.Sprintf can do it.

## First, create a solid CLI app. Then port it to the web via a JSON API, 
> that would simply consume the query string.


In Go this might be best done as a non-main package with a cmd folder that 
has a folder for the server and a folder for the CLI app.

I'm thinking of implementing a lexer/parser for this, but first I'd like to 
> make sure I'm not going to reinvent the wheel :)


It sounds like you are reinventing SQL. Why do you need a DSL?

Matt

On Friday, March 2, 2018 at 7:45:19 AM UTC-6, Benjamin Thomas wrote:
>
> Hello gophers,
>
> Sorry if this is considered noise to some, as I have a question which is 
> not specifically go related.
>
> I have a personal project in which I'd like to use go though.
>
> Basically, I'd like to create a complex search form, returning data backed 
> by an SQL database.
>
> To prevent SQL injection and for flexibility, I'm set on using an sql 
> builder library.
>
> However I'm not sure how to go about querying the data itself, via query 
> params, without creating lots of boiler plate and duplication.
>
> I'm wondering if a solution similar to what I'm looking for exists, as 
> I've never stumbled upon one...
>  
> I'm submitting my thoughts below, and would greatly appreciate feedback :)
>
> ===NOTES_START===
> # Idea for query params, for a search form.
>
> Upon UI changes, javascript would generate the appropriate final query 
> string
>
> A query string could be typed in by a power user, to handle cases not 
> covered by a simpler UI (via the url or text input)
>
> ## First, create a solid CLI app. Then port it to the web via a JSON API, 
> that would simply consume the query string.
>
> ```
> go run ./cmd/query/main.go QUERY_STRING
> ```
>
> ## Query string format would follow this principle
>
> PARAM_NAME : VALUE : OPERATOR
>
> ```
> # Commands
> columns:posted_on,short_descr:eq
> columns:posted_on,short_descr:hide
> columns:posting_id,posted_on,short_descr:show
>
> limit:10:eq
> limit:10  # would default to `eq`?
>
> page:1
> page:2
> offset:20
>
> # Filtering
> euros:11.94 # would default to `eq`?
> euros:11.94:eq
> euros:100:lt
> euros:100:lte
>
> comment:FIXME # would default to `eq`?
> comment:FIXME:eq
> comment:NULL:eq
> comment:NULL:ne
> comment:%tickets%:like
> comment:%Tickets%:ilike
>
> payee:Amazon|Google:re # regex
> payee:AMAZON|Google:rei # regex, case insensitive
>
> ```
>
> ## Question: how would I chain commands? I cannot use & in urls.
>
> ### Maybe with a pipe char
>
> QUERY_STRING | QUERY_STRING | QUERY_STRING
>
> ### Or via AND, OR keywords
>
> ```
> qs=QUERY_STRING
>
> qs AND qs OR qs
> ```
>
> ### Boolean logic, force the use of parentheses?
>
> ```
> qs=QUERY_STRING
>
> (qs AND qs) OR (qs OR qs)
> ```
> ===NOTES_END===
>
> Basically, I guess I'm looking for some kind of DSL.
>
> I'm thinking of implementing a lexer/parser for this, but first I'd like 
> to make sure I'm not going to reinvent the wheel :)
>
> Thanks for your interest and input!
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Alibaba Cloud hash released official Go SDK v1.0.0

2018-03-02 Thread Henrik Johansson
I am sure it's really cool but the docs are in chinese I assume. Most other
projects speared by non native English speakers still write in English.

Is a translation available?

On Fri, Mar 2, 2018, 14:44  wrote:

> https://github.com/aliyun/alibaba-cloud-sdk-go
>
> Any questions you have when using it can be asked directly in the issue
> area
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Alibaba Cloud hash released official Go SDK v1.0.0

2018-03-02 Thread sdgrtong


https://github.com/aliyun/alibaba-cloud-sdk-go

Any questions you have when using it can be asked directly in the issue area

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] interface question

2018-03-02 Thread Lutz Horn

How can i get a list about which interface is implemented by this
struct methods?  (Because in Go there is no explicit interface
declaration.)


os.Open returns an os.File (https://golang.org/pkg/os/#Open).

os.File (https://golang.org/pkg/os/#File) has functions and methods 
listed in the index of os (https://golang.org/pkg/os/#pkg-index).


Lutz

--
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] General question: complex search form and query params

2018-03-02 Thread benjamin . guy . thomas
Hello gophers,

Sorry if this is considered noise to some, as I have a question which is 
not specifically go related.

I have a personal project in which I'd like to use go though.

Basically, I'd like to create a complex search form, returning data backed 
by an SQL database.

To prevent SQL injection and for flexibility, I'm set on using an sql 
builder library.

However I'm not sure how to go about querying the data itself, via query 
params, without creating lots of boiler plate and duplication.

I'm wondering if a solution similar to what I'm looking for exists, as I've 
never stumbled upon one...
 
I'm submitting my thoughts below, and would greatly appreciate feedback :)

===NOTES_START===
# Idea for query params, for a search form.

Upon UI changes, javascript would generate the appropriate final query 
string

A query string could be typed in by a power user, to handle cases not 
covered by a simpler UI (via the url or text input)

## First, create a solid CLI app. Then port it to the web via a JSON API, 
that would simply consume the query string.

```
go run ./cmd/query/main.go QUERY_STRING
```

## Query string format would follow this principle

PARAM_NAME : VALUE : OPERATOR

```
# Commands
columns:posted_on,short_descr:eq
columns:posted_on,short_descr:hide
columns:posting_id,posted_on,short_descr:show

limit:10:eq
limit:10  # would default to `eq`?

page:1
page:2
offset:20

# Filtering
euros:11.94 # would default to `eq`?
euros:11.94:eq
euros:100:lt
euros:100:lte

comment:FIXME # would default to `eq`?
comment:FIXME:eq
comment:NULL:eq
comment:NULL:ne
comment:%tickets%:like
comment:%Tickets%:ilike

payee:Amazon|Google:re # regex
payee:AMAZON|Google:rei # regex, case insensitive

```

## Question: how would I chain commands? I cannot use & in urls.

### Maybe with a pipe char

QUERY_STRING | QUERY_STRING | QUERY_STRING

### Or via AND, OR keywords

```
qs=QUERY_STRING

qs AND qs OR qs
```

### Boolean logic, force the use of parentheses?

```
qs=QUERY_STRING

(qs AND qs) OR (qs OR qs)
```
===NOTES_END===

Basically, I guess I'm looking for some kind of DSL.

I'm thinking of implementing a lexer/parser for this, but first I'd like to 
make sure I'm not going to reinvent the wheel :)

Thanks for your interest and input!

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: interface question

2018-03-02 Thread Tamás Gulácsi
Sorry, that only lists the defined interfaces.

As there's no explicit interface "implements" declaration, it is only 
checked at compile time.

For example, guru 
(https://docs.google.com/document/d/1_Y9xCEMj5S-7rv2ooHpZNH15JgRT5iM742gJkw5LtmQ/view#heading=h.f6hyappclfor)
 
can help.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: interface question

2018-03-02 Thread Tamás Gulácsi


> How can i get a list about which interface is implemented by this struct 
> methods?  (Because in Go there is no explicit interface declaration.)
>
> for example : io.Closer etc.
>

Every struct that has all the methods exactly as that interface defines - 
for io.Closer, a "Close() error" is enough.

But, here is a compilation: 
http://sweetohm.net/article/go-interfaces.en.html

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] interface question

2018-03-02 Thread k1attila1
Hi

Beginner question

I want to use this  :

  func Open(name string) (*File, error)

I would like to us *File as return value.

File is declared as :

type File struct {
*file // os specific
}

I understand it.

BUT

How can i get a list about which interface is implemented by this struct 
methods?  (Because in Go there is no explicit interface declaration.)

for example : io.Closer etc.

Thanyk you in advance





 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go list returning directory starting with underscore on Ubuntu

2018-03-02 Thread Michel Hollands
My mistake: there was no src directory under the gopath. It works now.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go list returning directory starting with underscore on Ubuntu

2018-03-02 Thread Sebastien Binet
Michel,

Could you post the output of 'go env' and the name of the directory from
which you re-ran 'go list'?

-s

sent from my droid

On Mar 2, 2018 9:38 AM, "Michel Hollands"  wrote:

> Hello Sebastien,
>
> After setting GOPATH it still occurs.
>
> Thanks,
>
> Michel
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go list returning directory starting with underscore on Ubuntu

2018-03-02 Thread Michel Hollands
Hello Sebastien,

After setting GOPATH it still occurs.

Thanks,

Michel 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] High precision timer data?

2018-03-02 Thread James Chacon
On Thu, Mar 1, 2018 at 11:07 PM, James Chacon 
wrote:

>
>
> On Thu, Mar 1, 2018 at 10:13 AM, Ian Lance Taylor  wrote:
>
>> On Thu, Mar 1, 2018 at 8:56 AM, James Chacon 
>> wrote:
>> >
>> > I know the time package includes support for using the cycle timer on
>> the
>> > machine (if available) to get high precision monotonic time
>> measurements.
>> >
>> > But...calling time.Now() appears to have a lot of overhead. Measuring
>> the
>> > delay between 2 consecutive calls gives me anywhere from 150ns to 900+ns
>> > depending on arch (linux and OS/X for these 2 examples).
>> >
>> > My problem is I'm writing an emulator for an 8 bit cpu and on certain
>> types
>> > of emulation I want it to run at original clock speeds (so 550ns clock
>> > cycles or so in this case). Just measuring time.Now() at the start of a
>> > cycle and then subtracting time.Now() at the end to sleep for remaining
>> > won't work if the overhead of the calls exceeds my cycle time like it's
>> > doing on OS/X. I'm assuming negligible enough overhead for time.Sleep().
>> >
>> > I know for benchmarking we deal with this by aggregating a lot of
>> samples
>> > and then dividing out. Is there a way to get the timer data much
>> quicker?
>> > I'm assuming on OS/X it's ending up doing the syscall for gettimeofday
>> (I
>> > recall an open bug somewhere) which is where the large jump comes from.
>> >
>> > Or should I just measure my average latency when initializing my
>> emulator
>> > and use that as a baseline for determining how much to sleep? i.e.
>> > effectively a mini benchmark on startup to determine local machine
>> average
>> > run time and assume some slop?
>>
>> I don't think there is any way we could make time.Now run noticeably
>> faster on Darwin.  It's not doing a system call of any sort.
>>
>>
> I'm reading time·now in the 1.9.2 sources and it clearly has a fallback
> path to invoking the gettimeofday call.
>
> I hadn't looked at 1.10 yet so I'll update and check my results there.
>
>
>> Your best bet, if you can assume you are running on amd64, is a tiny
>> bit of assembly code to execute the rdtsc instruction.  rdtsc has its
>> problems, but it will give you fairly accurate cycle time when it's
>> not way way off.
>>
>>
> I may go with that.
>
>
Wow...Ok, updating to 1.10 made a *huge* difference here. On 1.9.2 Darwin
was showing an average of 811ns for back to back time.Now() calls. On 1.10
it's 11-13ns :) I haven't tested amd64 linux yet but I'll assume it's
similar.

At that amount I can just go back to calling time.Now() at the start/end
and sleeping for the difference modula some slop.

James

-- 
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.
For more options, visit https://groups.google.com/d/optout.