[go-nuts] if i catch resp.StatusCode != http.StatusOK and return early from my function, do i still have to close resp.Body??

2018-01-27 Thread evan

in the code snippet below which is inside a function, is "defer 
resp.Body.Close() " in the appropriate position?
am i required to always do a  resp.Body.Close()?
...
resp, err := client.Do(req)

log.Printf("resp: %+v\n", resp)
if resp.StatusCode != http.StatusOK {
return errors.NewHTTPError(resp.StatusCode)
}

defer resp.Body.Close() 

-- 
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] why defer function with parentheses

2018-01-27 Thread Tamás Gulácsi
Defer defers the esecutiin of the following expression, but not the evaluation 
of the arguments.
So "defer fn(a==1)" will call fn when this function exists, with a bool that is 
true iff a _was_ 1 when the defer was registered.

-- 
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: if you use sql.NullXYZ, what else do you find yourself doing to make coding easier (or make your code more readable, etc...)

2018-01-27 Thread evan
thanks! seems to be working out for me too so far. makes me wonder what the 
use cases might be for sql.NullXYZ and other similar types from non-stdlib 
packages other than making the connection to db nulls more obvious maybe?

On Saturday, January 27, 2018 at 10:12:23 PM UTC+8, Reinhard Luediger wrote:
>
> For me it works perfect when I just define each nullable field as a 
> pointer in the struct which represents a da base record. If the struct 
> field is nil it will be null in the database and json encoding handles 
> these fields also correctly 

-- 
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: Web Framework for Beginners

2018-01-27 Thread Lucio


On Saturday, 27 January 2018 23:49:19 UTC+2, Pat Farrell wrote:
>
>
>
> On Saturday, January 27, 2018 at 4:34:39 PM UTC-5, Lars Seipel wrote:
>>
>> We're talking about a beginning Go programmer that has yet to learn how 
>> some of the more advanced parts of the language fit together properly. 
>
>
> Sorry, no. Folks coming from other languages want to know how to do the 
> usual stuff with go
> Seems like a reasonable requirement for me.
>
> I'm not sure I see the relevance here: evangelising to a choir of another 
religious inclination is a waste of time. Putting into the language 
features that may attract the followers of a different belief system 
involves prostituting the principles of the "purer" language. Why would you 
want that?

Lucio.

-- 
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] why defer function with parentheses

2018-01-27 Thread Flying
example :
fn := func() {
 fmt.Println(10)
}
defer fn()


my question is why use defer fn() not defer fn


when we use fn() here doesn't it mean call it 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.


[go-nuts] Re: projects using net/http

2018-01-27 Thread matthewjuran
Hi Keith,

Can you share some specific things you’d like to see already implemented? 
Serving JSON data and web pages to a browser seems like a straightforward 
project with the standard library examples and resources available with 
Internet search engines.

Here’s an official net/http server walkthrough: 
https://golang.org/doc/articles/wiki/

Matt

On Friday, January 26, 2018 at 9:26:24 AM UTC-6, Keith Brown wrote:
>
> Are there any open source projects which use net/http exclusively? I am 
> building something and would like to follow the best practices of a 
> project. I need to visualize a lot of json data in a form of tables/charts. 
>

-- 
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: Web Framework for Beginners

2018-01-27 Thread matthewjuran

>
> Interesting. Does this work on all browsers on all platforms? 


Untested here. I've seen it work on macOS with Safari, Chrome, and Firefox. 
The || is to support how different browsers indicate a back button press / 
back cache load.

Matt

On Saturday, January 27, 2018 at 3:49:19 PM UTC-6, Pat Farrell wrote:
>
>
>
> On Saturday, January 27, 2018 at 4:34:39 PM UTC-5, Lars Seipel wrote:
>>
>> We're talking about a beginning Go programmer that has yet to learn how 
>> some of the more advanced parts of the language fit together properly. 
>
>
> Sorry, no. Folks coming from other languages want to know how to do the 
> usual stuff with go
> Seems like a reasonable requirement for me.
>
> I will gladly grant that most of the frameworks for other languages are 
> huge, bloated messes that are not consistent, clean and worst, not 
> orthogonal, all of which are beauties of go's design. But a beautiful 
> design is not a good thing if you  can't write a simple application (web 
> app in this case) that actually works properly on browsers that real users 
> have in the real world.
>
> The "back button" issue has been around since folks first started web 
> writing applications in the mid-90s. Sadly, for a trivial problem 
> statement, its still a far more difficult issue than it should be.
>
> Simple stuff should be simple. Its the design goal of every modern tool. 
> For 99% of what I think I want, go meets it. But in the real world, users 
> expect GUIs and that means browsers. So the back and forward and refresh 
> buttons have to do the right thing.
>
> IMHO, YMMV, etc 
>

-- 
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: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread Andrew Bonventre
I flushed the cache and now see the correct output on
https://play.golang.org/p/-MKUWeDBml7


On Sat, Jan 27, 2018 at 4:42 PM Andrew Bonventre 
wrote:

> Looks like it. I’ll check it out.
> On Sat, Jan 27, 2018 at 3:20 PM Ian Lance Taylor  wrote:
>
>> [ +andybons, bradfitz ]
>>
>> Looks like something has gone wrong with the play.golang.org caching.
>>
>> Ian
>>
>> On Sat, Jan 27, 2018 at 10:18 AM,   wrote:
>> > I see the same thing. Changing even one character fixes the problem.
>> Even
>> > just adding white space to the code. If I copy the example from
>> > https://golang.org/ to the playground exactly (
>> > https://play.golang.org/p/-MKUWeDBml7 ) it also prints nothing.
>> >
>> > Strange
>> >
>> >
>> > On Saturday, January 27, 2018 at 5:42:44 AM UTC-5, Eyal Posener wrote:
>> >>
>> >> When I "Run", can't see the proper output, just "Program exited".
>> >>
>> >> Only after changing "Hello World" to another example and then back to
>> >> "Hello World" I see the right output:
>> >>
>> >> Hello, 世界 Program exited.
>> >
>> > --
>> > 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] Shared stdlib questions

2018-01-27 Thread Ian Lance Taylor
On Sat, Jan 27, 2018 at 1:44 AM, Serhat Şevki Dinçer  wrote:
>
> On Manjaro 64-bit with go 1.9.3 I am doing:
> go install -gcflags '-B -s' -ldflags '-s -w' -buildmode shared std
>
> I get two warnings many times:
> go/src/unicode/casetables.go:17:11: redundant type: CaseRange
> go/src/vendor/golang_org/x/net/http2/hpack/tables.go:131:13: redundant type:
> HeaderField
> What does that mean?

It means you used the -s option in -gcflags.  Why are you doing that?

The -s option tells the compiler to warn about composite literals that
can be simplified.


> Also I want to run go tests against that shared stdlib I just built (25 mb).
> Neither of these seem to be what I need:
> go test std
> go test -linkshared std
> How do I run go tests against libstd.so?

I'm not sure but I don't think there is a way to run the standard
library tests with a shared standard library.  The shared standard
library will only be used for packages that are not already in the
standard library.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Web Framework for Beginners

2018-01-27 Thread Pat Farrell


On Saturday, January 27, 2018 at 4:34:39 PM UTC-5, Lars Seipel wrote:
>
> We're talking about a beginning Go programmer that has yet to learn how 
> some of the more advanced parts of the language fit together properly. 


Sorry, no. Folks coming from other languages want to know how to do the 
usual stuff with go
Seems like a reasonable requirement for me.

I will gladly grant that most of the frameworks for other languages are 
huge, bloated messes that are not consistent, clean and worst, not 
orthogonal, all of which are beauties of go's design. But a beautiful 
design is not a good thing if you  can't write a simple application (web 
app in this case) that actually works properly on browsers that real users 
have in the real world.

The "back button" issue has been around since folks first started web 
writing applications in the mid-90s. Sadly, for a trivial problem 
statement, its still a far more difficult issue than it should be.

Simple stuff should be simple. Its the design goal of every modern tool. 
For 99% of what I think I want, go meets it. But in the real world, users 
expect GUIs and that means browsers. So the back and forward and refresh 
buttons have to do the right thing.

IMHO, YMMV, etc 

-- 
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: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread Andrew Bonventre
Looks like it. I’ll check it out.
On Sat, Jan 27, 2018 at 3:20 PM Ian Lance Taylor  wrote:

> [ +andybons, bradfitz ]
>
> Looks like something has gone wrong with the play.golang.org caching.
>
> Ian
>
> On Sat, Jan 27, 2018 at 10:18 AM,   wrote:
> > I see the same thing. Changing even one character fixes the problem. Even
> > just adding white space to the code. If I copy the example from
> > https://golang.org/ to the playground exactly (
> > https://play.golang.org/p/-MKUWeDBml7 ) it also prints nothing.
> >
> > Strange
> >
> >
> > On Saturday, January 27, 2018 at 5:42:44 AM UTC-5, Eyal Posener wrote:
> >>
> >> When I "Run", can't see the proper output, just "Program exited".
> >>
> >> Only after changing "Hello World" to another example and then back to
> >> "Hello World" I see the right output:
> >>
> >> Hello, 世界 Program exited.
> >
> > --
> > 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: Web Framework for Beginners

2018-01-27 Thread Lars Seipel
On Thu, Jan 25, 2018 at 01:26:00PM -0800, Florin Pățan wrote:
> I'm not saying that we should be against recommending the standard library, 
> by all means, it's one of the best assets of the language. But maybe it's 
> time we should think about saying: Start with this framework, insert 
> framework name here, and then, as you gain more Go knowledge, or you are 
> curious about how it's done, look into these packages, insert collection of 
> packages here, and finally, do not discount the standard library, as it is 
> very powerful and it can do a lot out of the box without introducing 
> further dependencies into your code. 

We're talking about a beginning Go programmer that has yet to learn how
some of the more advanced parts of the language fit together properly.
Now, assuming that actually understanding your program is a goal (in
contrast to just bashing things together until they appear to do what
you want), importing a huge and complex framework doesn't seem very
helpful to me, for the same reasons you start learning programming with
"Hello, world!" and not by extending a distributed database engine.

-- 
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: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread Ian Lance Taylor
[ +andybons, bradfitz ]

Looks like something has gone wrong with the play.golang.org caching.

Ian

On Sat, Jan 27, 2018 at 10:18 AM,   wrote:
> I see the same thing. Changing even one character fixes the problem. Even
> just adding white space to the code. If I copy the example from
> https://golang.org/ to the playground exactly (
> https://play.golang.org/p/-MKUWeDBml7 ) it also prints nothing.
>
> Strange
>
>
> On Saturday, January 27, 2018 at 5:42:44 AM UTC-5, Eyal Posener wrote:
>>
>> When I "Run", can't see the proper output, just "Program exited".
>>
>> Only after changing "Hello World" to another example and then back to
>> "Hello World" I see the right output:
>>
>> Hello, 世界 Program exited.
>
> --
> 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] How to get mount point or device name by directory?

2018-01-27 Thread Matt Harden
syscall.Stat_t does have the Dev field, which is documented by POSIX:
https://linux.die.net/man/2/stat: "The st_dev field describes the device on
which this file resides. (The major(3) and minor(3) macros may be useful to
decompose the device ID in this field.)"

In Go we don't have the major and minor macros but they are basically just
shufflings of the bits. Unfortunately they are not platform independent,
even between versions of Linux. Luckily that doesn't matter when you're
searching for the device.

If you run os.Stat on each file in /dev, you will find for example "sda3",
which will have a value in syscall.Stat_t.Rdev that will match the Dev
value of any file/directory in a filesystem mounted on that device.

Note that there can possibly be more than one device file that has the same
Rdev value, so you may get a different answer than what "df" does, for
example.

If you have the tool "di ", it can do all
this for you:

% di /boot/grub
Filesystem Mount   Size UsedAvail %Used  fs Type
/dev/sda1  /boot 235.3M68.0M   155.2M   34%  ext2
% di -n -f S /boot/grub
/dev/sda1


On Wed, Jan 24, 2018 at 3:08 AM Ian Lance Taylor  wrote:

> On Tue, Jan 23, 2018 at 5:35 PM, Matrix Neo 
> wrote:
> > Lan,
> > Thank you for  your reply. Yes, I'm using GNU/Linux. I lookup the
> > findmnt program your mentioned and find that doesn't meet the need.
> > For example, if /data is mounted on /dev/sda3 and the given dir is /data.
> > It's ok to use findmnt to get /dev/sda3. But if the given dir is
> > /data/test1,
> > the findmnt returns nothing.
>
> Sorry the suggestion didn't help, but in any case this is a GNU/Linux
> question, not a Go question as such.
>
> Ian
>
>
> > 在 2018年1月23日星期二 UTC+8下午10:39:58,Ian Lance Taylor写道:
> >>
> >> On Mon, Jan 22, 2018 at 10:11 PM, Matrix Neo 
> wrote:
> >> >
> >> >  I want to get the mount point or device name (like /dev/sda1) by
> >> > the
> >> > directory name. I try my best only to find syscall.Stat_t struct but
> >> > there
> >> > is no field to
> >> > point the information i need. So is there any way to implement this ?
> >>
> >> You neglected to say what kind of system you are running on.  If you
> >> are using GNU/Linux, then as far as I know this information is not
> >> available using `stat`.  You need to run the `findmnt` program or look
> >> in `/proc/self/mountinfo`.
> >>
> >> Ian
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to golang-nuts+unsubscr...@googlegroups.com.
> > 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.
>

-- 
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: [ANN] Go Jupyter kernel and an interactive REPL

2018-01-27 Thread Sebastien Binet
Just to say that neugram.io has also a Jupyter front-end. Here's an example
with 'my' high energy physics oriented libraries and Gonum:
https://mybinder.org/v2/gh/go-hep/binder/master


Now, Go has 3 Jupyter kernels :)

-s

sent from my droid

On Jan 27, 2018 8:18 PM, "Matt Harden"  wrote:

> That's very nice!
>
> On Wed, Jan 17, 2018 at 8:29 AM Glen Newton  wrote:
>
>> Wow! This is great and positions Go better in the 'data science' world!
>>
>> Thanks,
>> Glen
>>
>>
>> On Tuesday, January 16, 2018 at 8:53:39 AM UTC-5, Yu Watanabe wrote:
>>>
>>> Hi Gophers,
>>>
>>> I developed a new Go's Jupyter Notebook  kernel
>>> and REPL environment.
>>> I would like to announce it to golang users and hear feedback about it.
>>>
>>> https://github.com/yunabe/lgo - Go (golang) Jupyter Notebook kernel and
>>> an interactive REPL 
>>>
>>> Features:
>>> 1. You can write and execute Go code interactively on browsers and CUI
>>> console.
>>> 2. Full Go language spec support.
>>> 3. Code completion and code inspection
>>> 4. Display images, HTML, JavaScript, SVG etc..
>>> 5. Code cancellation
>>>
>>> Thanks to mybinder.org, we can try example notebooks without
>>> installation from this link:
>>> https://mybinder.org/v2/gh/yunabe/lgo-binder/master?
>>> filepath=basics.ipynb
>>>
>>> If you think it's interesting, please go through the instructions in
>>> README.md and install it in your Go environment.
>>>
>>> Thanks,
>>> yunabe
>>>
>>> Screenshots:
>>>
>>>
>>>
>>> 
>>>
>>> ** code inspection (Shift-Tab) **
>>>
>>> 
>>>
>>> ** code completion (Tab) **
>>>
>>> 
>>>
>>>
>>>
>>>
>>>
>>> --
>> 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.
>

-- 
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: [ANN] Go Jupyter kernel and an interactive REPL

2018-01-27 Thread Matt Harden
That's very nice!

On Wed, Jan 17, 2018 at 8:29 AM Glen Newton  wrote:

> Wow! This is great and positions Go better in the 'data science' world!
>
> Thanks,
> Glen
>
>
> On Tuesday, January 16, 2018 at 8:53:39 AM UTC-5, Yu Watanabe wrote:
>>
>> Hi Gophers,
>>
>> I developed a new Go's Jupyter Notebook  kernel and
>> REPL environment.
>> I would like to announce it to golang users and hear feedback about it.
>>
>> https://github.com/yunabe/lgo - Go (golang) Jupyter Notebook kernel and
>> an interactive REPL 
>>
>> Features:
>> 1. You can write and execute Go code interactively on browsers and CUI
>> console.
>> 2. Full Go language spec support.
>> 3. Code completion and code inspection
>> 4. Display images, HTML, JavaScript, SVG etc..
>> 5. Code cancellation
>>
>> Thanks to mybinder.org, we can try example notebooks without
>> installation from this link:
>> https://mybinder.org/v2/gh/yunabe/lgo-binder/master?filepath=basics.ipynb
>>
>> If you think it's interesting, please go through the instructions in
>> README.md and install it in your Go environment.
>>
>> Thanks,
>> yunabe
>>
>> Screenshots:
>>
>>
>>
>> 
>>
>> ** code inspection (Shift-Tab) **
>>
>> 
>>
>> ** code completion (Tab) **
>>
>> 
>>
>>
>>
>>
>>
>> --
> 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: Async process state snapshotting in Golang

2018-01-27 Thread jake6502
A couple of comments. 

This is probably obvious, but I wanted to point out that matthe...'s code 
would require *all *access to the map to be synchronized using the mutex. 
It's a simple and effective solution. One downside to his code is that it 
holds the lock for the duration of the Copy(). This may be unacceptable 
depending on the size of the map and your latency requirements. If the map 
is very, very large, this could block a writer for an indeterminate amount 
of time. 

If your map met the requirements for sync.Map 
, that struct contains a Range() method 
that allows for concurrent access. Depending on the requirements for the 
temporal strictness of the "snapshot", you could then use that function to 
create a copy without blocking other goroutines which might be attempting 
to write to the map. 

There are other, more complicated way that the Copy() lock time could be 
made constant, but they are significantly complicated. 



On Friday, January 26, 2018 at 9:56:38 PM UTC-5, matthe...@gmail.com wrote:
>
> Why not this?
>
> type StructMap map[string]*SomeStruct
>
> type SyncStructMap struct {
> *sync.Mutex // maybe change to *sync.RWMutex if there are mixed 
> read/write synced operations
> StructMap
> }
>
> func (a SyncStructMap) Copy() StructMap {
> out := make(StructMap)
> a.Lock()
> for key, value := range a.StructMap {
> out[key] = value
> }
> a.Unlock()
> return out
> }
>
> // call with go keyword to make it execute concurrently
> func (a SyncStructMap) EncodeAndWrite() {
> c := a.Copy()
> // encode c then write to file
> }
>
> Matt
>
> On Friday, January 26, 2018 at 4:02:09 PM UTC-6, Tamás Gulácsi wrote:
>>
>> Do those *SomeStruct change during map serialization, or only the map 
>> (new keys / delete keys)?
>> If they do, you'll have to lock them too, not just the map access!
>>
>>

-- 
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: Any plans to add ASN.1 PER support?

2018-01-27 Thread Matt Harden
It isn't something that is likely to be added to the stdlib. If anything, a
library like https://github.com/Logicalis/asn1 might be interested in
supporting it / accepting a pull request to add it.

On Fri, Jan 12, 2018 at 9:50 AM David Wahlstedt <
david.wahlstedt@gmail.com> wrote:

> ASN.1 is still alive and present in telecom applications. The PER encoding
> is missing in the go library, unfortunately...
>
>
> Den torsdag 11 januari 2018 kl. 20:04:50 UTC+1 skrev Pat Farrell:
>>
>> On Thursday, January 11, 2018 at 10:50:24 AM UTC-5, David Wahlstedt wrote:
>>>
>>> I wonder if there are any plans to add PER encoding/decoding support for
>>> ASN.1?
>>> I have looked around, and it seems that there isn't any project
>>> supporting this, currently.
>>>
>>
>> Wow, I haven't heard anyone ask for ASN.1 PER or DER in two decades.
>> I know it still is listed in the specs, but  ASN.1 was  worse than XML
>>
> --
> 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: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread jake6502
I see the same thing. Changing even one character fixes the problem. Even 
just adding white space to the code. If I copy the example from 
https://golang.org/ to the playground exactly ( 
https://play.golang.org/p/-MKUWeDBml7 ) it also prints nothing. 

Strange

On Saturday, January 27, 2018 at 5:42:44 AM UTC-5, Eyal Posener wrote:
>
> When I "Run", can't see the proper output, just "Program exited".
>
> Only after changing "Hello World" to another example and then back to 
> "Hello World" I see the right output:
>
> Hello, 世界 Program exited.
>

-- 
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: Web Framework for Beginners

2018-01-27 Thread Pat Farrell


On Thursday, January 25, 2018 at 8:38:01 PM UTC-5, matthe...@gmail.com 
wrote:
>
> Specific question: how do you handle the user hitting the "back" button on 
>> their browser? Its very common and a lot of simple approaches don't handle 
>> it well.
>
>
> This was a problem for me. I force the page to reload instead of using the 
> cache:
>
>
> // 
> https://stackoverflow.com/questions/8788802/prevent-safari-loading-from-cache-when-back-button-is-clicked/13123626#13123626
> // 
> https://stackoverflow.com/questions/17432899/javascript-bfcache-pageshow-event-event-persisted-always-set-to-false
> $(window).bind("pageshow", function(event) {
> if (event.originalEvent.persisted || (window.performance && (window.
> performance.navigation.type == 2))) {
> window.location.reload();
> }
> });
>
>
>
Interesting. Does this work on all browsers on all platforms? 

-- 
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: [ANN] gluo v0.0.2 released - Write your Go net/http server once, deploy it everywhere

2018-01-27 Thread Dario Castañé
Sure, that's possible. I will check and see how to implement it
properly.
Regards,

Dario Castañé
dario.im[1]


On Sat, Jan 27, 2018, at 13:34, anmol via golang-nuts wrote:
> What do you think about offering a second variant to allow passing
> in the http server? It's possible one may want to set limits or
> other configuration on the HTTP server instead of using the default
> http server.> 
> On Thursday, January 25, 2018 at 6:42:03 PM UTC-5, Dario
> Castañé wrote:>> I'm pleased to announce the launch of Gluo: a handy wrapper 
> for
>> net/http applications that allows to deploy the exact same binary to
>> AWS Lambda and (bare-metal/virtual) servers.>> 
>> https://github.com/imdario/gluo
>> 
>> If you want to use your current net/http code with little
>> modification, Gluo is your choice. It's a drop-in replacement: just
>> call gluo.ListenAndServe instead of http.ListenAndServe.>> 
>> PS: version 0.0.1 was released the same day as AWS announced their
>> official support for Go in AWS Lambda, but I waited for a second
>> release in order to improve code coverage.>> 
>> Dario Castañé
>> dario.im[2]
>> 
> 


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

Links:

  1. https://dario.im/
  2. https://dario.im/

-- 
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: [ANN] go-resty v1.1 released - Simple HTTP and REST client library

2018-01-27 Thread matthewjuran
Hi Jeeva,

Thanks for sharing go-resty here. I’d like to mention that my input about 
struct embedding may not be valid. It was pointed out to me previously when 
I made a similar suggestion that in library design embedding exports all of 
the embedded type’s methods, so you may have those named fields because of 
that.

Thanks,
Matt

On Thursday, January 25, 2018 at 8:53:33 PM UTC-6, Jeevanandam M. wrote:
>
> Thank you Matt for your inputs and suggestions. I will look into it.
>
> Cheers,
> Jeeva
>
>
> On Thursday, January 25, 2018 at 3:36:44 PM UTC-8, matthe...@gmail.com 
> wrote:
>>
>> Hi Jeeva, here’s a code review.
>>
>> In client.go *Client R() the creation of the *Request unnecessarily sets 
>> zero values for fields. They could just be omitted instead. Same in 
>> default.go at func createClient.
>>
>> The Client type could have *log.Logger and http.Header embedded in the 
>> struct instead of named. This would shorten calls elsewhere (like c.Printf 
>> instead of c.Log.Printf).
>>
>> In middleware.go func parseRequestBody using else instead of goto may be 
>> clearer.
>>
>> In redirect.go I’m not understanding the RedirectPolicy interface + 
>> RedirectPolicyFunc type. Why not just have “type RedirectPolicy func(req 
>> *http.Request, via []*http.request) error”?
>>
>> Request could have multiple exported fields embedded. Perhaps Request in 
>> Response too.
>>
>> There are a lot of tests, nice.
>>
>> I’m not sure why there’s a utility valueOf func instead of just calling 
>> reflect.ValueOf directly.
>>
>> For documentation I feel that Client has too many functions, methods, and 
>> fields, but I’m not sure what an alternative would look like. Perhaps these 
>> types could rely on setting public fields instead of having setters in some 
>> cases? And maybe Client could be broken into subtypes embedded into the 
>> Client struct.
>>
>> Some godoc identifier documentation is missing the period. The README.md 
>> has many examples which may already be covered by godoc that are making it 
>> longer than usual.
>>
>> Matt
>>
>> On Thursday, January 25, 2018 at 2:27:46 PM UTC-6, Jeevanandam M. wrote:
>>>
>>> Stable Version : gopkg.in/resty.v1
>>> Edge Version   : github.com/go-resty/resty
>>> godoc  : https://godoc.org/github.com/go-resty/resty
>>>
>>>
>>> Changelog:
>>>
>>> Features:
>>>   * Added Request URL Path Params #103 @jeevatkm
>>>
>>> Enhancements:
>>>   * Auto detects file content type in mutlipart/form-data mode #109, PR 
>>> #111 @gh0st42 
>>>   * Limit body size for debug log PR #99 @sudo-suhas
>>>   * Log prefix enhancement #113 @jeevatkm
>>>   * More friendly with mocking test libraries
>>>
>>> I appreciate your support & feedback!
>>>
>>> Cheers,
>>> Jeeva
>>>
>>

-- 
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] gomobile bind -target=ios ld: framework not found OpenGL

2018-01-27 Thread jpteasdale
I'm having a problem building an ios framework that depends on a OpenGL 
library. 

if this is the file:

package gfx


import (
 "github.com/goxjs/gl"
)


func test() {
 gl.Clear(gl.COLOR_BUFFER_BIT)
}


This is the build output:
gomobile bind -target=ios
gomobile: go install 
-pkgdir=/Users/johnteasdale/gocode/pkg/gomobile/pkg_darwin_arm 
-tags ios github.com/jpteasdale/gfx failed: exit status 2 
# github.com/jpteasdale/gfx/vendor/github.com/go-gl/gl/v2.1/gl 
ld: framework not found OpenGL 
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)



I know where the framework is:

ls /System/Library/Frameworks/OpenGL.framework
Headers Libraries Modules OpenGL Resources Versions



I've tried all of the following with the same result:

gomobile bind -target=ios -ldflags "-L /System/Library/Frameworks"

gomobile bind -target=ios -ldflags "-F /System/Library/Frameworks"

gomobile bind -target=ios -ldflags "-extldflags -F 
/System/Library/Frameworks"

LDFAGS="-F/System/Library/Frameworks" gomobile bind -target=ios

CGO_LDFLAGS="-F /System/Library/Frameworks" gomobile bind -target=io



There isn't much documentaiton on this, so I was hoping one of y'all had 
seen this before.

Versions:
macOS 10.13.2 

go version

go version go1.9.2 darwin/amd64

gomobile version

gomobile version +5704e18 Mon Jan 22 17:02:51 2018 + (android,ios); 
androidSDK=


clang -v

Apple LLVM version 9.0.0 (clang-900.0.39.2)

Target: x86_64-apple-darwin17.3.0

Thread model: posix

InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

-- 
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] if you use sql.NullXYZ, what else do you find yourself doing to make coding easier (or make your code more readable, etc...)

2018-01-27 Thread 'Reinhard Luediger' via golang-nuts
For me it works perfect when I just define each nullable field as a pointer in 
the struct which represents a da base record. If the struct field is nil it 
will be null in the database and json encoding handles these fields also 
correctly 

-- 
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: [ANN] gluo v0.0.2 released - Write your Go net/http server once, deploy it everywhere

2018-01-27 Thread anmol via golang-nuts
What do you think about offering a second variant to allow passing in the 
http server? It's possible one may want to set limits or other 
configuration on the HTTP server instead of using the default http server.

On Thursday, January 25, 2018 at 6:42:03 PM UTC-5, Dario Castañé wrote:
>
> I'm pleased to announce the launch of Gluo: a handy wrapper for net/http 
> applications that allows to deploy the exact same binary to AWS Lambda and 
> (bare-metal/virtual) servers.
>
> https://github.com/imdario/gluo
>
> If you want to use your current net/http code with little modification, 
> Gluo is your choice. It's a drop-in replacement: just call 
> gluo.ListenAndServe instead of http.ListenAndServe.
>
> PS: version 0.0.1 was released the same day as AWS announced their 
> official support for Go in AWS Lambda, but I waited for a second release in 
> order to improve code coverage.
>
> Dario Castañé
> dario.im
>
>

-- 
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] ssh cause db disconnect

2018-01-27 Thread tuanhoanganh
Hello.
I have db connect open before run ssh command. But after run ssh command db
connect will be disconnect

Is there anyway to fix it.

Thanks you very much.

Tuan

-- 
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: Table Driven Test (TDT) and log only failed test case

2018-01-27 Thread Jérôme LAFORGE
Of course, that was I already did. But I talk about the log into function I 
want to test (in the example of playground:  func IsBuggyEven) .
see: 
https://play.golang.org/p/OWnEntLwfXa


check 0 is even or odd, but I want see this log only for fail test case 
(i.e when i == 5)
check 2 is even or odd, but I want see this log only for fail test case 
(i.e when i == 5)
check 5 is even or odd, but I want see this log only for fail test case 
(i.e when i == 5)
--- FAIL: TestIsEven (0.00s)
--- FAIL: TestIsEven/5_is_even (0.00s)
/tmp/somewhere/mmoney_test.go:144: For 5, expected: false, actual: 
true
FAIL
FAILcommon/utils0.044s
Error: Tests failed.


Le samedi 27 janvier 2018 10:30:27 UTC+1, Tamás Gulácsi a écrit :
>
> Use subtest (t.Run)

-- 
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] "Try Go" in golang.org stopped working properly?

2018-01-27 Thread Eyal Posener
When I "Run", can't see the proper output, just "Program exited".

Only after changing "Hello World" to another example and then back to 
"Hello World" I see the right output:

Hello, 世界 Program exited.

-- 
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] Shared stdlib questions

2018-01-27 Thread Serhat Şevki Dinçer
Hi,
On Manjaro 64-bit with go 1.9.3 I am doing:
go install -gcflags '-B -s' -ldflags '-s -w' -buildmode shared std

I get two warnings many times:
go/src/unicode/casetables.go:17:11: redundant type: CaseRange
go/src/vendor/golang_org/x/net/http2/hpack/tables.go:131:13: redundant 
type: HeaderField
What does that mean?

Also I want to run go tests against that shared stdlib I just built (25 
mb). Neither of these seem to be what I need:
go test std
go test -linkshared std
How do I run go tests against libstd.so?

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.


[go-nuts] Table Driven Test (TDT) and log only failed test case

2018-01-27 Thread Tamás Gulácsi
Use subtest (t.Run)

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