[go-nuts] [ANN]Route aws lambda requests using existing standard http router library such as mux or bone.

2018-03-11 Thread davy zhang
https://github.com/davyzhang/agw

A small library I used for many of my projects.

When I use aws lambda to handle the requests from apigateway, it is pretty 
annoying to handle different requests with a single lambda function due to 
the fact that apigateway does not pass all the HTTP information as 
http.Request. Instead, it uses a JSON object to store all the relevant 
information.

So, I write this library to convert it back to a http.Request. Hope this 
can help some of you guys who have the similar problems.

-- 
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: constructors vs lazy initialization

2018-03-11 Thread matthewjuran

>
> I prefer the later when possible because it enables callers to use the 
> zero value of a type without explicit initialisation.


Two great standard library examples of this are sync.Mutex / sync.RWMutex 
and bytes.Buffer / strings.Builder.

Matt

On Saturday, March 3, 2018 at 9:20:11 PM UTC-6, Dave Cheney wrote:
>
> I prefer the later when possible because it enables callers to use the 
> zero value of a type without explicit initialisation.
>
> On Sunday, 4 March 2018 11:37:43 UTC+11, Anmol Sethi wrote:
>>
>> How do you guys choose between constructors and lazy initialization?
>>
>> For example.
>>
>> Struct constructors:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func newMeow() *meow {
>> return {
>> x: http.NewServeMux(),
>> }
>> }
>>
>> func (m *meow) do() {
>> // stuff
>> }
>>
>>
>> Lazy initialization:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func (m *meow) do() {
>> if m.x == nil {
>> m.x = http.NewServeMux()
>> }
>> // stuff
>> }
>>
>>

-- 
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: Flutter and golang

2018-03-11 Thread matthewjuran
For my web application I previously reached the conclusion that the best 
approach is to write independent clients with the platform programming and 
visual design language instead of trying something cross-platform.

I can see Flutter or QT being great for “we need this to work everywhere 
and can sacrifice quality”, but for cases where I really need the 
performance and look (which I don’t imagine shares a lot between platforms) 
is there argument against just having a native app calling a Go library for 
the HTTP client functionality?

Matt

On Saturday, March 10, 2018 at 2:28:19 PM UTC-6, Ged Wed wrote:
>
> I am starting to develop an app using flutter and golang.
>
> Flutter is the dumb GUI and everything else is written in golang.
>
> It is reasonably easy to compile your golang code using gomobile and then 
> bind to flutter using the Method Channel API that flutter provides.
>
> Is anyone interested in this ?
>
> Flutter now runs on all desktops and mobiles officially. The desktop 
> version was announced 2 weeks ago and already Linux and macOS works, with 
> Windows probably being a few weeks away from what I guesstimate.
>
> The cool thing about this is that you get a very well supported and high 
> performance GUI engine for Forms and 2D. 3D is still not provided by has 
> been stated by the team to be looked at later.
>
> Anyway I hope to spark some interest in this and I will be putting up some 
> demo code on my git hub repo and hope others are interested enough to also 
> give it a try and work through it.
>
>
> How to write a plug-in:
>
> https://flutter.io/platform-channels/
>
> Plugins already available :
>
> https://pub.dartlang.org/flutter/packages
>
> Printing.
> They have not yet officially committed to how cross platform out put to 
> PDF and XPS ( for windows ) will be supported.
> Under the covers Flutter is using the same engine that Google Chrome 
> browser uses; called Skia.
>
> Skia has an API for printing web pages and it uses pdfium under the hood.
> It seams logical that the Flutter team will also start using this method 
> to provide built in PDF output and even print spooling but from what I can 
> see it's not resolved yet.
>
> All other things like touch, keyboard, sound, gestures etc are all built 
> into Flutter because it's built into Skia.
>
> Would be great to hear if there is a strong interest in this and to 
> discuss .
>
>

-- 
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: Flutter and golang

2018-03-11 Thread Ged Wed
This is the repo the flutter team are doing the flutter desktop.

https://github.com/google/flutter-desktop-embedding

It's the same code as runs on mobile essentially except they have an embedding 
API designed into flutter to allow it to be embedded onto desktop.

I am not 100% sure because it's only been up for 2 weeks but I think they are 
using glfw to embed on Windows, macOS and Linux.

The maxIS works today . I have tried it.
Linux apparently works.
Windows is being worked on.

It's not a huge take to support desktops because flutter and skia do 99% of the 
work and they have planned desktops architecturally for a long time by having 
their embedding API.

It's not plain sailing yet !.it's only been 2 weeks..but it's getting commits 
every day and docs and easy make files are not quite there yet.

That's why I started the CI project. To build up the make files and the 
continuous builds on the various CI cloud based platforms 

I am using bitrise which is a great CI platform that is 100% written in golang 
too. 
They virtualize macOS using VMware virt.
But the exact same CI script you can run on your own macOS too.
They don't support Windows. So I guess I will use appveyor.

Luckily setting up a script to install flutter is 2 lines of code for windows 
or other OS's

Hope this helps.

-- 
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: constructors vs lazy initialization

2018-03-11 Thread snmed
But this is only working as long as you do not need any services or 
dependencies. And in that case i would really appreciate if the language 
natively supports a nil check on method parameters at compile time.
For all cases where nil is a valid value, the language needs a marker to 
allow such cases. In my opinion it would save some nil checks and makes it 
much more clear for the caller what the method is expecting.



Am Sonntag, 4. März 2018 04:20:11 UTC+1 schrieb Dave Cheney:
>
> I prefer the later when possible because it enables callers to use the 
> zero value of a type without explicit initialisation.
>
> On Sunday, 4 March 2018 11:37:43 UTC+11, Anmol Sethi wrote:
>>
>> How do you guys choose between constructors and lazy initialization?
>>
>> For example.
>>
>> Struct constructors:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func newMeow() *meow {
>> return {
>> x: http.NewServeMux(),
>> }
>> }
>>
>> func (m *meow) do() {
>> // stuff
>> }
>>
>>
>> Lazy initialization:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func (m *meow) do() {
>> if m.x == nil {
>> m.x = http.NewServeMux()
>> }
>> // stuff
>> }
>>
>>

-- 
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] Help On Kqueue Server

2018-03-11 Thread Jesper Louis Andersen
On Sat, Mar 10, 2018 at 10:19 AM Anto Aravinth 
wrote:

> Hello all,
>
> I'm learning golang and I wanted to try out this. Wanted to make a event
> driven server using Kqueue sys call (I'm on mac). A simple echo server will
> do.
>

If you want to learn this, I suggest you start off with something like C
which the kqueue/kevent interface was built for. A Go-idiomatic solution
would usually abstract this away by means of using goroutines[0].

Also, you code seems to be missing part of the usual socket interface.
Calling net.Listen creates a Listener from which you can draw connections
through the means of Accept(). You want the file descriptors of accepted
sockets in your case I think.

In Go, an acceptor pool would usually spawn of goroutines which will then
accept on the socket and do concurrent work. Note that there are many
considerations in building a robust acceptor pool in general (and I would
wager several exist of varying levels of stability).

[0] On Mac and BSD, the interface is usually kqueue/kevent. On Linux a
completely different epoll() interface exist (which is a slightly bonkers
API IMO), and on Illumos you have event ports filling in the same problem
space.

Interestingly, systems such as Node.js is just a wrapper on top of these
eventing systems, to which you've frankensteined in a Javascript JIT on the
side. There are many limitations to such a system with regard to system
stability and latency. Especially as projects grow large.

-- 
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: [Advice needed] How to vendor common dependencies for plugins

2018-03-11 Thread Jay Guo
Bump.. any thoughts? Thanks!

- J

On Thursday, March 8, 2018 at 2:03:37 PM UTC+8, Jay Guo wrote:
>
> Golang gurus,
>
> I'm currently trying to modularize my project with the help of Golang 
> plugin, and I come across this dependency vendoring dilemma.
>
> Let's say we have a project layout:
>
>- Two different projects in separate repo: `Host` and `Guest`
>- `Host` depends on package `pkgA`
>- `Guest` depends on package `pkgA` too
>- `Guest` is compiled as plugin, and loaded by `Host`
>- `pkgA` is vendored into both `Host` and `Guest`
>
> In this situation, `pkgA` would be loaded twice and independently, meaning 
> there are two instance of the package in the program, one lives in `Guest` 
> and one in `Host`. init() would be called twice as well
>
> Particularly, I'm dealing with golang.org/x/net/trace package, which 
> actually registers an endpoint /debug/requests. The second attempt would 
> panic because of double-registration.
>
> I'd appreciate any advice on how to manage common dependencies of plugin 
> and main project, thank you!
>
> - 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.