[go-nuts] Re: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Uli Kunitz
It must be something in your setup. It works for me here with Chrome 
55.0.2883.87 
m (64-bit) on Windows 10 Home 1604 Build 14393.576.

On Thursday, December 29, 2016 at 11:25:40 PM UTC+1, Mahdi Ziraki wrote:
>
> so far:
> firefox & chrome Ubuntu 16.0.4 works fine.
> firefox & chrome Android 7.1.1 works fine.
> edge, firefox & chrome Windows 10 returns http/1.1 (but it works fine with 
> "github.com/davecheney/httpstat")
>
> On Friday, December 30, 2016 at 12:11:21 AM UTC+3:30, Mahdi Ziraki wrote:
>>
>>
>>

-- 
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] Re: How has your company adopted Go ?

2016-12-29 Thread Haddock
Thanks Henrik and Eric. Replacing some service to start with bridging Java 
and Go through http or nats is a good idea. I'll pick that one up ;-).

Am Donnerstag, 29. Dezember 2016 23:41:35 UTC+1 schrieb Eric Johnson:
>
> Stand-alone services are definitely the way to go. Pick a small service 
> that either is yet to be written, or is performing badly in its current 
> Java implementation.
>
> Eric
>
> On Dec 29, 2016, at 12:35 AM, Haddock  wrote:
>
> This thread is very interesting to me as I'm working exclusively with Java 
> and am looking for ways to bring in other approaches such as using Go. 
> Could some of you drop some few lines in what way in your company Java is 
> combined with Go? That would give me an idea where to start experimenting 
> in order to show some use cases to my boss.
>
> Thanks, Haddock
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/golang-nuts/UE8NGYbb6ec/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> golang-nuts...@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] [ANN] Luar v2

2016-12-29 Thread 'Peter Neidhardt' via golang-nuts
I'd like to announce Luar v2, the Lua reflection bindings for Go (based on
Arzilli's Golua).

Luar is a convenience bridge between Lua and Go, with awesomeness like:

- Modify Go data (maps, structures, you name it) from Lua using regular Lua
syntax (e.g. `m[3] = 17` and `m.field = 'foobar'`).

- Conversely, modify Lua data (tables, userdata with metatables) from Go.

- Call Go functions from Lua over a mix of Go and Lua arguments.

- Likewise, call Lua functions from Go.

- Use Go channels from Lua.

- Use Lua regular `for` construct to loop over Go maps, slices, strings, etc.

- Loop over Lua data from a Go `for`.

See some examples on godoc: https://godoc.org/gopkg.in/stevedonovan/luar.v2.

This library is not new, as Luar was first released a few years ago by Steve
Donovan, then left unmaintained for a while. I took over maintenance and
rewrote most of the API to simplify its use:

- Reflection is no longer required from the caller side.

- I've halved the number of exported functions.

- Easier of use (less parameters).

- Cyclic structures are supported on both sides.

- Initialization of the Lua state is optional and can be completely customized.

- LuaToGo handles more conversions and allows for merging Lua data into existing
maps.

- LuaObjects support __call/__index/__newindex metamethods.

- LuaObject's Get*()/Set() functions support subfield indexing.

- Does not panic. (At least not when it can be avoided.)

- Tons of bug fixes.

v2 is still in development, any feedback is very welcome.

--
Peter Neidhardt

-- 
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: Do you guys use ORMs when working with SQL?

2016-12-29 Thread a . modzelewski
I far prefer solutions like Squirrel 
(https://github.com/Masterminds/squirrel) to ORMs for most problems — I 
still write queries, but use a more convenient syntax. It also means I'm 
less likely to somehow accidentally introduce an injection vulnerability. 
Usually that's enough abstraction to get me started on actual work.

On Tuesday, December 27, 2016 at 11:00:05 PM UTC+1, Zippoxer wrote:
>
> I haven't written SQL for years. I was enjoying MongoDB with the awesome 
> mgo package, and what saved me a lot of headache was the natural 
> programmatic interface of MongoDB.
> mgo maps your data (structs, maps, slices) to MongoDB queries and from 
> MongoDB results, and you can write any MongoDB query possible with the 
> mgo/bson package exclusively.
>
> I've seen the sqlx package which only does mapping of results from the 
> database, but not the other way around -- so you still have to type some 
> queries like this:
> func InsertFoo(v Foo) {
> db.Exec(`INSERT INTO x (bla, bla2, bla3, bla4, bla5, bla6, ...) 
> VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ...)`, v.bla, v.bla2, v.bla3, 
> v.bla4, v.bla5, v.bla6, ...)}
> }
>
> I can live with this verbosity, but that's not my problem. What happens 
> when you add a field to the struct *Foo*? You have to modify the query 
> above in three places and make sure you typed every character correctly.
> And there are probably more queries updating *Foo*. Seems like too much 
> manual maintenance to do -- and I believe this increases the chance of bugs.
>
> A classic solution to this problem would be to use an ORM. I've looked at 
> SQLBoiler  and I'm very excited to 
> see an ORM that generates Go code instead of using reflection. However, it 
> still has the classic problem of ORMs that we all discuss from time to time.
> Like any ORM, due to it being an additional layer on top of the database, 
> it adds complexity (instead of verbosity and the manual query maintenance 
> above) and you might have to write raw SQL anyway (what if you only want to 
> select 2 fields of Foo instead of all of them? what about complex queries?)
>
> Considering all that, I still cannot reach a conclusion. I'm going back 
> and forth on that issue.
>
> Since I appreciate the opinions of this community more than any other 
> community I know right now, can you guys pour your opinions on the matter?
>

-- 
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] Re: How to use ~/ in terminal with go program?

2016-12-29 Thread Aurélien DESBRIÈRES
What do you mean by more safe?

On Fri, Dec 30, 2016, 4:04 AM Matt Harden  wrote:

> Based on Jan's reply, https://play.golang.org/p/-7NUaJwoOf is a little
> more safe.
>
> On Thu, Dec 29, 2016 at 8:13 AM Aurélien Desbrières <
> aurelien.desbrie...@gmail.com> wrote:
>
> The original code is https://play.golang.org/p/CTbhTC50eE
> It is write to works as:
>
> go run gocat.go
>
> Here is how it works at this time.
>
> $ go run gocat.go
> Which file would you like to read?: ~/bob
> 2016/12/29 17:10:19 my program broken
> exit status 1
>
> $ go run gocat3.go
> Which file would you like to read?: /home/aurelien/bob
> hmm hmm
>
> --
>
> 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] custom json unmarshaling between object or arrays

2016-12-29 Thread Matt Harden
https://play.golang.org/p/gWQuthS0D6

On Wed, Dec 28, 2016 at 11:55 PM Sathish VJ  wrote:

> aah, got it. the case []interface{}:  is what I'd not gotten right.
> Thanks for the detailed examples.
>
>
> On Thursday, 29 December 2016 12:57:54 UTC+5:30, Konstantin Khomoutov
> wrote:
>
> On Wed, 28 Dec 2016 21:55:33 -0800 (PST)
>
> Sathish VJ  wrote:
>
> > I'm trying to do custom json unmarshaling when there could be an
> > error.
> >
> > In case there is an error, it will have json like: { "error": "err
> > msg"} Else, it could be anything.
> >
> > If it is another json object, then I'm having no issues.  But if the
> > incoming data is an array, then it fails.  How do I take care of this
> > case?
> >
> > source: https://play.golang.org/p/xyiDWZh9Rt
>
> One way around this is to rely on Go's encoding/json doing the Right
> Thing™ when unmarshaling into a value of type interface{}.
> This way, you'll get an appropriately-typed value as a result, and
> could do type switching on it [1].
>
> The downside of this approach is that if your "non-error case" JSON
> streams are compilcated, and you'd like to actually parse them into
> objects of your custom (struct) types, this approach would require
> re-parsing the source JSON stream for a non-error case.
> You can get around this problem by resorting to low-level parsing of
> the JSON stream and switching the processing logic as soon as you
> detect you were sent a JSON object (which might contain the
> field "error" signalizing an error).  Unfortunately, the JSON decoder
> seems to not support "peeking" at the next token or "pushing back" the
> just read token so you'll need to resort to a somewhat contrived
> solution such as [2], which I'd use only if your "non-error case" data
> streams are large enough to warrant such dancing.
>
> You could also condider exploring 3rd-party JSON decoders such as [3] or
> [4] which might contain enough controls to facilitate such fine-grained
> parsing you need.
>
> 1. https://play.golang.org/p/VVm6pxN8rh
> 2. https://play.golang.org/p/6wntcKxKBR
> 3. https://github.com/ugorji/go
> 4. https://github.com/clbanning/mxj
>
> --
> 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] Re: How to use ~/ in terminal with go program?

2016-12-29 Thread Matt Harden
Based on Jan's reply, https://play.golang.org/p/-7NUaJwoOf is a little more
safe.

On Thu, Dec 29, 2016 at 8:13 AM Aurélien Desbrières <
aurelien.desbrie...@gmail.com> wrote:

> The original code is https://play.golang.org/p/CTbhTC50eE
> It is write to works as:
>
> go run gocat.go
>
> Here is how it works at this time.
>
> $ go run gocat.go
> Which file would you like to read?: ~/bob
> 2016/12/29 17:10:19 my program broken
> exit status 1
>
> $ go run gocat3.go
> Which file would you like to read?: /home/aurelien/bob
> hmm hmm
>
> --
> 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] Re: Do you guys use ORMs when working with SQL?

2016-12-29 Thread Jakub Labath
Hi,

When I gave some thought to the whole ORM, I concluded it was not the SQL 
that bothered me it was these items

1. Adding a new column to table means having to revisit every 
query/insert/update that could be affected
2. Serializing and de-serializing as things get saved/read from DB (dealing 
with null values, date time conversions, blobs that should be parsed into 
e.g. json etc.)

So rather than create some magical layer above SQL I simply attempted to 
abstract the above items into one place.
So that when adding a new column one only has to adjust the serializer and 
de-serializer methods, and when querying one simply omits listing the 
columns.

Here my attempt at the above - https://github.com/jlabath/dbi

Cheers

Jakub Labath

On Tuesday, December 27, 2016 at 10:00:05 PM UTC, Zippoxer wrote:
>
> I haven't written SQL for years. I was enjoying MongoDB with the awesome 
> mgo package, and what saved me a lot of headache was the natural 
> programmatic interface of MongoDB.
> mgo maps your data (structs, maps, slices) to MongoDB queries and from 
> MongoDB results, and you can write any MongoDB query possible with the 
> mgo/bson package exclusively.
>
> I've seen the sqlx package which only does mapping of results from the 
> database, but not the other way around -- so you still have to type some 
> queries like this:
> func InsertFoo(v Foo) {
> db.Exec(`INSERT INTO x (bla, bla2, bla3, bla4, bla5, bla6, ...) 
> VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ...)`, v.bla, v.bla2, v.bla3, 
> v.bla4, v.bla5, v.bla6, ...)}
> }
>
> I can live with this verbosity, but that's not my problem. What happens 
> when you add a field to the struct *Foo*? You have to modify the query 
> above in three places and make sure you typed every character correctly.
> And there are probably more queries updating *Foo*. Seems like too much 
> manual maintenance to do -- and I believe this increases the chance of bugs.
>
> A classic solution to this problem would be to use an ORM. I've looked at 
> SQLBoiler  and I'm very excited to 
> see an ORM that generates Go code instead of using reflection. However, it 
> still has the classic problem of ORMs that we all discuss from time to time.
> Like any ORM, due to it being an additional layer on top of the database, 
> it adds complexity (instead of verbosity and the manual query maintenance 
> above) and you might have to write raw SQL anyway (what if you only want to 
> select 2 fields of Foo instead of all of them? what about complex queries?)
>
> Considering all that, I still cannot reach a conclusion. I'm going back 
> and forth on that issue.
>
> Since I appreciate the opinions of this community more than any other 
> community I know right now, can you guys pour your opinions on the matter?
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread John C.
I show http/2 working at https://http2.golang.org/ on Win10 x64 with 
Chrome 56.0.2924.28 beta (64-bit).  Home internet connection, ordinary 
neighborhood internet provider.



On Thursday, December 29, 2016 at 4:39:02 PM UTC-5, Dave Cheney wrote:
>
> Right, so it's a bug with chrome on windows. 

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
nothing found!

On Friday, December 30, 2016 at 2:59:33 AM UTC+3:30, 
r...@skyportsystems.com wrote:
>
> is it possible your windows host is behind either an explicit proxy or a 
> transparent proxy (like bluecoat)? 
>
> for the explicit case, 
>
> reg query 
> "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 
> Settings"
>
> look for "proxyserver" or "AutoConfigURL"
>
>
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread rsr via golang-nuts
is it possible your windows host is behind either an explicit proxy or a 
transparent proxy (like bluecoat)? 

for the explicit case, 

reg query 
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 
Settings"

look for "proxyserver" or "AutoConfigURL"


-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
can you suggest any solution about how can I fix this?

On Friday, December 30, 2016 at 1:46:30 AM UTC+3:30, Dave Cheney wrote:
>
> Can any windows users reproduce this issue?
>
> On Friday, 30 December 2016 08:48:36 UTC+11, Mahdi Ziraki wrote:
>>
>> it's response with http/1.1 not just in chrome for windows, it has same 
>> issue with edge & firefox too! and it's behaving like this just for golang 
>> code, it's ok for other sites (google, youtube & etc.)
>>
>> On Friday, December 30, 2016 at 1:09:02 AM UTC+3:30, Dave Cheney wrote:
>>>
>>> Right, so it's a bug with chrome on windows. 
>>
>>

-- 
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] Re: How has your company adopted Go ?

2016-12-29 Thread 'Eric Johnson' via golang-nuts
Stand-alone services are definitely the way to go. Pick a small service
that either is yet to be written, or is performing badly in its current
Java implementation.

Eric

On Dec 29, 2016, at 12:35 AM, Haddock  wrote:

This thread is very interesting to me as I'm working exclusively with Java
and am looking for ways to bring in other approaches such as using Go.
Could some of you drop some few lines in what way in your company Java is
combined with Go? That would give me an idea where to start experimenting
in order to show some use cases to my boss.

Thanks, Haddock

-- 
You received this message because you are subscribed to a topic in the
Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/golang-nuts/UE8NGYbb6ec/unsubscribe.
To unsubscribe from this group and all its topics, 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] Re: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
so far:
firefox & chrome Ubuntu 16.0.4 works fine.
firefox & chrome Android 7.1.1 works fine.
edge, firefox & chrome Windows 10 returns http/1.1 (but it works fine with 
"github.com/davecheney/httpstat")

On Friday, December 30, 2016 at 12:11:21 AM UTC+3:30, Mahdi Ziraki wrote:
>
>
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Dave Cheney
Can any windows users reproduce this issue?

On Friday, 30 December 2016 08:48:36 UTC+11, Mahdi Ziraki wrote:
>
> it's response with http/1.1 not just in chrome for windows, it has same 
> issue with edge & firefox too! and it's behaving like this just for golang 
> code, it's ok for other sites (google, youtube & etc.)
>
> On Friday, December 30, 2016 at 1:09:02 AM UTC+3:30, Dave Cheney wrote:
>>
>> Right, so it's a bug with chrome on windows. 
>
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
it's response with http/1.1 not just in chrome for windows, it has same 
issue with edge & firefox too! and it's behaving like this just for golang 
code, it's ok for other sites (google, youtube & etc.)

On Friday, December 30, 2016 at 1:09:02 AM UTC+3:30, Dave Cheney wrote:
>
> Right, so it's a bug with chrome on windows. 

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
I tested httpstat and got http/2, so how http2 in all windows browsers 
(edge, firefox, chrome) have same bug?!

On Friday, December 30, 2016 at 1:01:38 AM UTC+3:30, Dave Cheney wrote:
>
> You could try 
>
> GitHub.com/davecheney/httpstat 
>
> Which is a simple curl replacement written in Go which supports http/2 
> natively. 
>
> If that is able to negotiate a http/2 request then the problem is likely 
> on your windows machine. 
>
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Dave Cheney
Right, so it's a bug with chrome on windows. 

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Eric Brown
Thank you, Dave.  That was just code I copied & pasted, and removed pieces 
while in the textarea submit box on this page.  I didn't know about this 
way of the map lookup... thanks.  I'm still learning Go.  It's actually my 
first language, and still need to look into coding standards and syntax, 
which I'm sure you could tell looking at my mess.  Again, appreciate your 
help!1234

On Thursday, December 29, 2016 at 3:25:29 PM UTC-6, Dave Cheney wrote:
>
> Also, try using the two return value version of a map lookup to avoid 
> having to recover from a nil pointer error when unlocking a non existent 
> lock value. 
>
> https://tour.golang.org/moretypes/22
>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Eric Brown
Appreciate the sample, very much.  Go is my first language, and still 
learning.  It's just a hobby at the moment (which I'm sure you can tell by 
my amateur code).  Still need to learn about coding standards, etc.

On Thursday, December 29, 2016 at 2:13:54 PM UTC-6, Val wrote:
>
> Hi Eric
> here is some sample code, with
> - a "correct" implementation  : it 
> passes the race detector, and it behaves as expected : no overlapping of 
> queries on a specific file.
> - an "incorrect" impl  that doesn't 
> guard the map : it would seem like it works, but the race detector 
> immediately reports the fraud.
>
> The only subtle thing is to not confuse the mutex for the map, and the 
> mutex for each file.  There should not exist a "function that handles the 
> unlocking of the map[string]*sync.Mutex",  the map access itself is 
> ultra-fast and the map locking should be nothing more than   mutex.Lock() ; 
> defer mutex.Unlock() .  It is important to release the global mutex 
> *before* executing the sqlite query.
>
> For the general problem of re-acquiring a mutex, I learned today in the 
> archives that code involving recursive (reentrant) mutex locking is frowned 
> upon, regarded as a code smell, a bad practice that is very bug-prone.
>
> Cheers
> Val
>
> On Thursday, December 29, 2016 at 7:43:19 PM UTC+1, Eric Brown wrote:
>>
>> Thanks Val, I actually tried that approach... and failed.  Perhaps I 
>> incorporated it wrong.  I put the handling of locking/unlocking of the 
>> map[string]*sync.Mutex in it's own function, which was encapsulated in the 
>> global mutex like you suggested.  Only problem was, was that the database 
>> function ran once... because when it went to call the function that handled 
>> the unlocking of the map[string]*sync.Mutex, it was already locked by a 
>> previous goroutine trying to lock the map[string]*sync.Mutex.
>>
>> Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't 
>> help that I'm fairly new to this type of stuff in Go.  Appreciate you 
>> assistance, however.  Thank you!
>>
>>
>>
>> On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:
>>>
>>> Hello Eric
>>> You may use a map[string]*sync.Mutex where key is the DB filepath, and 
>>> protect that map with a global mutex.
>>>
>>> Note that a mutex value must not be copied, often it is necessary to use 
>>> pointers.
>>>
>>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
I tested this on 2 PCs and got same issue.
then on android it was ok.
at last on ubuntu it was ok too.

On Friday, December 30, 2016 at 1:00:14 AM UTC+3:30, Dave Cheney wrote:
>
> Either this is a bug in chrome on windows, or it's something related to 
> your network setup. 
>
> I don't think the bug is in Go's http/2 implementation. 
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Dave Cheney
You could try 

GitHub.com/davecheney/httpstat 

Which is a simple curl replacement written in Go which supports http/2 
natively. 

If that is able to negotiate a http/2 request then the problem is likely on 
your windows machine. 

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
I used this sample code:

package main

import (
"fmt"
"log"
"net/http"
"strings"
)

func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(formatRequest(req)))
})
log.Fatalln(http.ListenAndServeTLS(":443", "certificate.crt", 
"private.key", nil))
}

func formatRequest(r *http.Request) string {
var request []string
url := fmt.Sprintf("%v %v %v", r.Method, r.URL, r.Proto)
request = append(request, url)
request = append(request, fmt.Sprintf("Host: %v", r.Host))
for name, headers := range r.Header {
name = strings.ToLower(name)
for _, h := range headers {
request = append(request, fmt.Sprintf("%v: %v", name, h))
}
}
return strings.Join(request, "\n")
}

to test it h2 on myself and it's behaving like http2.golang.org too.
see: https://goshop.ddns.net/ (it's ok on linux & android but not in 
windows!)

On Friday, December 30, 2016 at 12:50:20 AM UTC+3:30, Dave Cheney wrote:
>
> Do you have any av software on your computer that may be enforcing a proxy?
>
> Does your environment enforce a proxy?
>

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Dave Cheney
Either this is a bug in chrome on windows, or it's something related to your 
network setup. 

I don't think the bug is in Go's http/2 implementation. 

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
yes, but I use same VPN that I use in my phone! but it's behaving like this 
only on Windows, and it's ok on Linux Ubuntu & Android!

On Friday, December 30, 2016 at 12:50:20 AM UTC+3:30, Dave Cheney wrote:
>
> Do you have any av software on your computer that may be enforcing a proxy?
>
> Does your environment enforce a proxy?
>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Dave Cheney
Also, try using the two return value version of a map lookup to avoid having to 
recover from a nil pointer error when unlocking a non existent lock value. 

https://tour.golang.org/moretypes/22

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Dave Cheney
This code does not compile, your unlock function has an unused variable.

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Dave Cheney
Do you have any av software on your computer that may be enforcing a proxy?

Does your environment enforce a proxy?

-- 
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: https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki
it's fine in chrome for android but not in chrome for windows (or any other 
browsers for windows)!

-- 
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] https://http2.golang.org/ shows http/2 disabled on chrome but it's not!

2016-12-29 Thread Mahdi Ziraki


-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Eric Brown
Sorry, left some comments and stuff in there.  Tried to condense it as much 
as possible.

On Thursday, December 29, 2016 at 2:16:46 PM UTC-6, Eric Brown wrote:
>
> package configurationLockExample
>
> import (
> "sync"
> )
>
> type _lockReference struct {
> fileIdentifier map[string]*sync.Mutex
>
> var (
> _configurationLock _lockReference
> _lockReferenceLock sync.RWMutex
> )
>
> func init() {
> _configurationLock.fileIdentifier = make(map[string]*sync.Mutex)
> }
>
> func (lockReference *_lockReference) Lock(identifier string) {
> _lockReferenceLock.Lock()
>
> if _, hasKey := lockReference.fileIdentifier[identifier]; hasKey {
> // - reserved for future development; intentionally left blank
> } else { // mutex not already constructed in referenced map; construct 
> it
> lockReference.fileIdentifier[identifier] = {}
> }
>
> lockReference.fileIdentifier[identifier].Lock()
>
> _lockReferenceLock.Unlock()
> }
>
> func (lockReference *_lockReference) Unlock(identifier string) {
> _lockReferenceLock.Lock()
>
> defer func() {
> errorReturn := recover()
> _lockReferenceLock.Unlock()
> }()
>
> lockReference.fileIdentifier[identifier].Unlock()
> }
>
> func (lockReference *_lockReference) Delete(identifier string) {
> _lockReferenceLock.Lock()
>
> if _, hasKey := lockReference.fileIdentifier[identifier]; hasKey
> delete(lockReference.fileIdentifier, identifier)
> }
>
> _lockReferenceLock.Unlock()
> }
>
> func StoreConfiguration(configurationFile string, recordName string, 
> recordContent string) error {
>
> _configurationLock.Lock(configurationFile)
>
> defer _configurationLock.Delete(configurationFile)
> defer _configurationLock.Unlock(configurationFile)
>
> // handle configuration stuff here
> }
>
> On Thursday, December 29, 2016 at 1:13:50 PM UTC-6, Dave Cheney wrote:
>>
>> Could you show some code, perhaps we can spot the point you're going 
>> wrong.
>>
>> On Friday, 30 December 2016 05:43:19 UTC+11, Eric Brown wrote:
>>>
>>> Thanks Val, I actually tried that approach... and failed.  Perhaps I 
>>> incorporated it wrong.  I put the handling of locking/unlocking of the 
>>> map[string]*sync.Mutex in it's own function, which was encapsulated in the 
>>> global mutex like you suggested.  Only problem was, was that the database 
>>> function ran once... because when it went to call the function that handled 
>>> the unlocking of the map[string]*sync.Mutex, it was already locked by a 
>>> previous goroutine trying to lock the map[string]*sync.Mutex.
>>>
>>> Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't 
>>> help that I'm fairly new to this type of stuff in Go.  Appreciate you 
>>> assistance, however.  Thank you!
>>>
>>>
>>>
>>> On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:

 Hello Eric
 You may use a map[string]*sync.Mutex where key is the DB filepath, and 
 protect that map with a global mutex.

 Note that a mutex value must not be copied, often it is necessary to 
 use pointers.

>>>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Eric Brown
package configurationLockExample

import (
"sync"
)

type _lockReference struct {
fileIdentifier map[string]*sync.Mutex

var (
_configurationLock _lockReference
_lockReferenceLock sync.RWMutex
)

func init() {
_configurationLock.fileIdentifier = make(map[string]*sync.Mutex)
}

func (lockReference *_lockReference) Lock(identifier string) {
_lockReferenceLock.Lock()

if _, hasKey := lockReference.fileIdentifier[identifier]; hasKey {
// - reserved for future development; intentionally left blank
} else { // mutex not already constructed in referenced map; construct 
it
lockReference.fileIdentifier[identifier] = {}
}

lockReference.fileIdentifier[identifier].Lock()

_lockReferenceLock.Unlock()
}

func (lockReference *_lockReference) Unlock(identifier string) {
_lockReferenceLock.Lock()

defer func() {
errorReturn := recover()
_lockReferenceLock.Unlock()
}()

lockReference.fileIdentifier[identifier].Unlock()
}

func (lockReference *_lockReference) Delete(identifier string) {
_lockReferenceLock.Lock()

if _, hasKey := lockReference.fileIdentifier[identifier]; hasKey
delete(lockReference.fileIdentifier, identifier)
}

_lockReferenceLock.Unlock()
}

func StoreConfiguration(configurationFile string, recordName string, 
recordContent string) error {

_configurationLock.Lock(configurationFile)

defer _configurationLock.Delete(configurationFile)
defer _configurationLock.Unlock(configurationFile)

// handle configuration stuff here
}

On Thursday, December 29, 2016 at 1:13:50 PM UTC-6, Dave Cheney wrote:
>
> Could you show some code, perhaps we can spot the point you're going wrong.
>
> On Friday, 30 December 2016 05:43:19 UTC+11, Eric Brown wrote:
>>
>> Thanks Val, I actually tried that approach... and failed.  Perhaps I 
>> incorporated it wrong.  I put the handling of locking/unlocking of the 
>> map[string]*sync.Mutex in it's own function, which was encapsulated in the 
>> global mutex like you suggested.  Only problem was, was that the database 
>> function ran once... because when it went to call the function that handled 
>> the unlocking of the map[string]*sync.Mutex, it was already locked by a 
>> previous goroutine trying to lock the map[string]*sync.Mutex.
>>
>> Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't 
>> help that I'm fairly new to this type of stuff in Go.  Appreciate you 
>> assistance, however.  Thank you!
>>
>>
>>
>> On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:
>>>
>>> Hello Eric
>>> You may use a map[string]*sync.Mutex where key is the DB filepath, and 
>>> protect that map with a global mutex.
>>>
>>> Note that a mutex value must not be copied, often it is necessary to use 
>>> pointers.
>>>
>>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Val
Hi Eric
here is some sample code, with
- a "correct" implementation  : it 
passes the race detector, and it behaves as expected : no overlapping of 
queries on a specific file.
- an "incorrect" impl  that doesn't 
guard the map : it would seem like it works, but the race detector 
immediately reports the fraud.

The only subtle thing is to not confuse the mutex for the map, and the 
mutex for each file.  There should not exist a "function that handles the 
unlocking of the map[string]*sync.Mutex",  the map access itself is 
ultra-fast and the map locking should be nothing more than   mutex.Lock() ; 
defer mutex.Unlock() .  It is important to release the global mutex *before* 
executing the sqlite query.

For the general problem of re-acquiring a mutex, I learned today in the 
archives that code involving recursive (reentrant) mutex locking is frowned 
upon, regarded as a code smell, a bad practice that is very bug-prone.

Cheers
Val

On Thursday, December 29, 2016 at 7:43:19 PM UTC+1, Eric Brown wrote:
>
> Thanks Val, I actually tried that approach... and failed.  Perhaps I 
> incorporated it wrong.  I put the handling of locking/unlocking of the 
> map[string]*sync.Mutex in it's own function, which was encapsulated in the 
> global mutex like you suggested.  Only problem was, was that the database 
> function ran once... because when it went to call the function that handled 
> the unlocking of the map[string]*sync.Mutex, it was already locked by a 
> previous goroutine trying to lock the map[string]*sync.Mutex.
>
> Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't help 
> that I'm fairly new to this type of stuff in Go.  Appreciate you 
> assistance, however.  Thank you!
>
>
>
> On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:
>>
>> Hello Eric
>> You may use a map[string]*sync.Mutex where key is the DB filepath, and 
>> protect that map with a global mutex.
>>
>> Note that a mutex value must not be copied, often it is necessary to use 
>> pointers.
>>
>

-- 
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: NPN disabled in chrome

2016-12-29 Thread Mahdi Ziraki
I found out NPN is not the issue, because golang supports ALPN but I don't 
know what's the reason to this issue.

I ran a test on a PC & Android and got this:
https://github.com/golang/go/issues/18462#issuecomment-269681906

On Thursday, December 29, 2016 at 9:49:16 PM UTC+3:30, Mahdi Ziraki wrote:
>
> today I noticed my project stopped to serve http/2 and serves http/1.1 
> after lots of search I found this:
>
>
> https://ma.ttias.be/day-google-chrome-disables-http2-nearly-everyone-may-31st-2016/
>
> and I noticed http2.golang.org stopped working correctly like my project 
> in chrome v55 for Windows.
>
> I want to know anyone else has this issue or is just me?
>
> BTW: http2.golang.org in google chrome for android works fine!
>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Dave Cheney
Could you show some code, perhaps we can spot the point you're going wrong.

On Friday, 30 December 2016 05:43:19 UTC+11, Eric Brown wrote:
>
> Thanks Val, I actually tried that approach... and failed.  Perhaps I 
> incorporated it wrong.  I put the handling of locking/unlocking of the 
> map[string]*sync.Mutex in it's own function, which was encapsulated in the 
> global mutex like you suggested.  Only problem was, was that the database 
> function ran once... because when it went to call the function that handled 
> the unlocking of the map[string]*sync.Mutex, it was already locked by a 
> previous goroutine trying to lock the map[string]*sync.Mutex.
>
> Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't help 
> that I'm fairly new to this type of stuff in Go.  Appreciate you 
> assistance, however.  Thank you!
>
>
>
> On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:
>>
>> Hello Eric
>> You may use a map[string]*sync.Mutex where key is the DB filepath, and 
>> protect that map with a global mutex.
>>
>> Note that a mutex value must not be copied, often it is necessary to use 
>> pointers.
>>
>

-- 
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: concurrent sqlite database access... how to handle?

2016-12-29 Thread Eric Brown
Thanks Val, I actually tried that approach... and failed.  Perhaps I 
incorporated it wrong.  I put the handling of locking/unlocking of the 
map[string]*sync.Mutex in it's own function, which was encapsulated in the 
global mutex like you suggested.  Only problem was, was that the database 
function ran once... because when it went to call the function that handled 
the unlocking of the map[string]*sync.Mutex, it was already locked by a 
previous goroutine trying to lock the map[string]*sync.Mutex.

Hahaha... I hope I made sense.  My brain is hurting here.  It doesn't help 
that I'm fairly new to this type of stuff in Go.  Appreciate you 
assistance, however.  Thank you!



On Thursday, December 29, 2016 at 1:28:34 AM UTC-6, Val wrote:
>
> Hello Eric
> You may use a map[string]*sync.Mutex where key is the DB filepath, and 
> protect that map with a global mutex.
>
> Note that a mutex value must not be copied, often it is necessary to use 
> pointers.
>

-- 
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] NPN disabled in chrome

2016-12-29 Thread m . zirakit
today I noticed my project stopped to serve http/2 and serves http/1.1 
after lots of search I found this:

https://ma.ttias.be/day-google-chrome-disables-http2-nearly-everyone-may-31st-2016/

and I noticed http2.golang.org stopped working correctly like my project in 
chrome v55 for Windows.

I want to know anyone else has this issue or is just me?

BTW: http2.golang.org in google chrome for android works fine!

-- 
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] Re: How has your company adopted Go ?

2016-12-29 Thread Henrik Johansson
For us they interact exclusively through either plain http based services
or via Nats, no other interactions take place. It works as expected without
any particular issues. I would suggest that you start with a similar
approach and create a self contained little service to show that Go not
only works but runs fast and safe. If you are on the docker track try to
demonstrate the outstanding startup speed by using something like Alpine or
even scratch as base image.

On Wed, Dec 28, 2016, 22:34 Haddock  wrote:

> This thread is very interesting to me as I'm working exclusively with Java
> and am looking for ways to bring in other approaches such as using Go.
> Could some of you drop some few lines in what way in your company Java is
> combined with Go? That would give me an idea where to start experimenting
> in order to show some use cases to my boss.
>
> Thanks, Haddock
>
> --
> 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] Re: How to use ~/ in terminal with go program?

2016-12-29 Thread Aurélien Desbrières
The original code is https://play.golang.org/p/CTbhTC50eE
It is write to works as:

go run gocat.go

Here is how it works at this time.

$ go run gocat.go
Which file would you like to read?: ~/bob
2016/12/29 17:10:19 my program broken
exit status 1

$ go run gocat3.go
Which file would you like to read?: /home/aurelien/bob
hmm hmm

-- 
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] Re: How to use ~/ in terminal with go program?

2016-12-29 Thread Jan Mercl
On Thu, Dec 29, 2016 at 2:41 PM Aurélien Desbrières <
aurelien.desbrie...@gmail.com> wrote:

Something like https://play.golang.org/p/v0qPerJi4y ?
-- 

-j

-- 
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] Re: How to use ~/ in terminal with go program?

2016-12-29 Thread Aurélien Desbrières
Oh so that is not an official stuff from go but an outside library ~_~
Is there any ways more "official" to do that?

On Thursday, December 29, 2016 at 7:17:02 AM UTC+1, Aurélien Desbrières 
wrote:
>
> That sounds good. I will try it and tell you back. Thanks 
>
> On Thu, Dec 29, 2016, 5:02 AM Caleb Doxsey wrote:
>
>> You can use this library: 
>> https://godoc.org/github.com/mitchellh/go-homedir#Expand
>>
>>
>> On Wednesday, December 28, 2016 at 8:22:06 AM UTC-5, Aurélien Desbrières 
>> wrote:
>>>
>>> As explain ~/ in golang  , I 
>>> am trying to request the user to cat a file with a gocat program.
>>>
>>> The point is that if the user tell to the terminal the full address, 
>>> /home/user/file, the program works, but if the user use ~/file the program 
>>> brokes.
>>>
>>> How can I use Golang to use ~/ in terminal request?
>>>
>>
>>

-- 
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: Behaviour manifested by select statement

2016-12-29 Thread Caleb Doxsey
Use time.After:

package main

import (
"log"
"math/rand"
"time"
)

func randomSleep(min, max int64) <-chan time.Time {
rand.Seed(time.Now().UnixNano())
sleepDuration := time.Duration(rand.Int63n(max-min)+min) * 
time.Millisecond
log.Printf("Sleep duration: %v\n", sleepDuration)
return time.After(sleepDuration)
}

func main() {
select {
case <-time.After(1000 * time.Millisecond):
log.Println("time after chan triggered")
case <-randomSleep(1000, 2000):
log.Println("rand sleep triggered")
}
}

https://play.golang.org/p/nHOPEJ8URz

On Wednesday, December 28, 2016 at 2:46:03 PM UTC-5, Abhishek Singh wrote:
>
> Hi,
>
> Below is a sample example, where I'm trying to understand behaviour of 
> select statement. I was hoping the time.After() case clause to succeed but 
> observation is that either of those clauses are executed intermittently. 
> Would help if someone could share what's going on.
>
> func randomSleep(min, max int64) time.Duration {
> rand.Seed(time.Now().UnixNano())
> sleepDuration := time.Duration(rand.Int63n(max-min)+min) * time.Millisecond
> log.Printf("Sleep duration: %v\n", sleepDuration)
> time.Sleep(sleepDuration)
> return sleepDuration
> }
>
> func main() {
> sendCh := make(chan time.Duration, 1)
> select {
> case <-time.After(1000 * time.Millisecond):
> log.Println("time after chan triggered")
> case sendCh <- randomSleep(1000, 2000):
> log.Println("rand sleep triggered")
> }
> }
>
> Go Playground - https://play.golang.org/p/6SosvxOUGL
>
> 
>
> I understand, I could workaround this behaviour via:
>
> func main() {
> sendCh := make(chan time.Duration, 1)
> go func () { sendCh <- randomSleep(1000, 2000) }()
> select {
> case <-time.After(1000 * time.Millisecond):
> log.Println("time after chan triggered")
> case <-sendCh:
> log.Println("rand sleep triggered")
> }
> }
>
> Thanks.
>

-- 
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] Re: Chrome not accepting generate_cert.go self-signed SSL certificate

2016-12-29 Thread Marcus Franke
Chrome, like the other browsers use your systems certificate store. Just
import the root CA's certificate and you will have a valid chain of trust.

Darren Hoo  schrieb am Do., 29. Dez. 2016, 09:04:

> Try starting chrome from command line with option --ignore-certificate-errors
> ?
>
>
> On Friday, March 13, 2015 at 7:19:07 PM UTC+8, Alex wrote:
>
>
> I made a certificate with the generate_cert.go file in the http package,
> and it works fine on firefox, but chrome wont accept it (with no options to
> allow), and I cant find it in the certificates settings in chrome to
> manually allow the certificate either.
>
> I used the -ca=true flag when creating the certificate.
>
> Does anyone know if there is something I can modify when creating the
> certificate to make it work in chrome?
>
> Thanks,
>
> --
> 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] How to invoke methods with variant interface when you have array of interface?

2016-12-29 Thread Dave Cheney
Like this:

ver s string
var args []interface
fn(s, args...)

https://golang.org/ref/spec#Passing_arguments_to_..._parameters

-- 
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 has your company adopted Go ?

2016-12-29 Thread Haddock
This thread is very interesting to me as I'm working exclusively with Java 
and am looking for ways to bring in other approaches such as using Go. 
Could some of you drop some few lines in what way in your company Java is 
combined with Go? That would give me an idea where to start experimenting 
in order to show some use cases to my boss.

Thanks, Haddock

-- 
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] How to invoke methods with variant interface when you have array of interface?

2016-12-29 Thread jishnu


I am newbie in Go please bear with me 

I have to invoke a method in another package 


*someFunc(query string, args ...interface{})*


I have 2 variable of type *string ,[]interface{} *Is it possible to invoke 
the above method? If yes how?


Regards

Jishnu

-- 

--
IMPORTANT: This is an e-mail from HiFX IT Media Services Pvt. Ltd. Its 
content are confidential to the intended recipient. If you are not the 
intended recipient, be advised that you have received this e-mail in error 
and that any use, dissemination, forwarding, printing or copying of this 
e-mail is strictly prohibited. It may not be disclosed to or used by anyone 
other than its intended recipient, nor may it be copied in any way. If 
received in error, please email a reply to the sender, then delete it from 
your system. 

Although this e-mail has been scanned for viruses, HiFX cannot ultimately 
accept any responsibility for viruses and it is your responsibility to scan 
attachments (if any).

​
Before you print this email or attachments, please consider the negative 
environmental impacts associated with printing.

-- 
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: Chrome not accepting generate_cert.go self-signed SSL certificate

2016-12-29 Thread Darren Hoo
Try starting chrome from command line with option --ignore-certificate-errors 
?


On Friday, March 13, 2015 at 7:19:07 PM UTC+8, Alex wrote:
>
>
> I made a certificate with the generate_cert.go file in the http package, 
> and it works fine on firefox, but chrome wont accept it (with no options to 
> allow), and I cant find it in the certificates settings in chrome to 
> manually allow the certificate either.
>
> I used the -ca=true flag when creating the certificate.
>
> Does anyone know if there is something I can modify when creating the 
> certificate to make it work in chrome?
>
> Thanks,
>

-- 
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.