[go-nuts] rplidar_sdk_go - controlling the RPLidar scanner from Go

2018-10-10 Thread Simon Ritchie
Slamtec's RPLidar scanner is used in robotics, SLAM and solid modelling 
applications.  It's a small, light and cheap Lidar solution - versions are 
available for about $80.

Slamtec publish what they describe as an SDK.  Strictly it's just a C++ 
library of control methods and a few example applications.

I've written a wrapper for the C++ library that allows you to control the 
scanner from a Go program.  You can find that here: 
https://github.com/goblimey/rplidar_sdk_go.

Slamtec's C++ library is open source and is implemented for Windows, Mac 
and Linux systems.  I've only tested it under Linux so far.  Unfortunately, 
the Windows build requires a particular version of Visual Studio, which was 
a blocker for me.

I used cgo to call the C++ methods from Go.  There is a huge range of C and 
C++ libraries out there, and cgo potentially opens up access to them.  
However, the Slamtec library is not directly compatible with cgo and I had 
to jump through a few hoops to use it.  I describe them in the project 
README.  Anybody planning a similar project may get some useful advice 
there.

Enjoy!

-- 
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] cgo use question

2018-09-30 Thread Simon Ritchie
Aagh!  I misunderstood the question.  Apologies for that.

There may still be a grain of usefulness in my answer.  There are limits to the 
complexity of the C code that you can call with cgo.  (It’s even worse if you 
are calling C++, as I was.)  You can magic away a lot of those problems by 
writing an extra layer of C that hides the complexities.

However, this probably involves having make around to bind everything together. 
 I agree that this is a nuisance, because your user may not have make, 
particularly if they are using Windows.  There is a version of gnu make 
available for that, but using it just led me to a different world of pain.

Have you considered having two separate pieces of software, one in C and one in 
Go and linking them together with grpc?  That would allow you to ship your 
solution as two binaries.

-- 
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] cgo use question

2018-09-30 Thread Simon Ritchie
Write a separate package to handle the C stuff and call it from the other two.

I built a wrapper for a  c++ library:  
https://github.com/goblimey/rplidar_sdk_go.  The c++ code used various features 
that defeated cgo, so I ended up with a multi-layered solution.

One thing I discovered is that cgo has a nasty habit of rewriting the Go code 
that calls C code, including trampling on your comments, so keeping that code 
in  a separate layer is a good idea.

-- 
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] Selenium webdriver based testing in Go

2018-01-05 Thread Simon Ritchie
I’ve used the Selenium Firefox plugin to test web servers written in Go.  It’s 
great for end to end testing of a web server because it doesn’t know or care 
what the server is written in.  It’s only concerned with the resulting HTML.

I recorded some web sessions using the plugin and can then play them back to 
test any changes to the code.  The sessions are recorded in plain text so you 
can edit the description and replace any variable content with wildcards.  For 
example,  one of the tests involved creating an object using fixed values.  The 
resulting page displays the result including the UID, so it’s mostly the same 
each time except for the UID.  My edited Selenium script checks each field but 
uses a wildcard for the UID.

There are lots of web scripting systems that do this sort of testing, but 
Selenium is the only one I know about that has a nice easy visual interface and 
is free.

-- 
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: gRPC golang server and client testing

2017-11-11 Thread Simon Ritchie
Not everybody in the Go community favours the use of mocking tools, so many 
published solutions don't have any tests of that kind.   Maybe you should 
write the tests yourself.

I use pegomock for mocking.  (I tried gomock but I found issues that were 
not fixed.  I also found a couple of issues with pegomock too, but the 
author fixed them.)

Pegomock tool is a fairly conventional mocking tool.  Given an interface, 
it produces a concrete class that implements the interface and can be told 
at runtime how to respond to a method call.  So anything you test has to be 
defined by an interface.  Of course, if you only have a concrete class, Go 
allows you to create your own interface that matches it, so that's not a 
big problem.

If you want some worked examples of pegomock, see my 
scaffolder https://github.com/goblimey/scaffolder.  It generates a web 
server with pegomock tests for some of the components.

Regards

Simon  

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


[go-nuts] Re: How to learn golang web development

2017-10-14 Thread Simon Ritchie
 
Not a book, but a simple working example. 

My scaffolder tool generates a web server in source code from a 
specification.

https://github.com/goblimey/scaffolder

The distribution includes an example specification, so you can just 
download the tool, run the example and look at the result.

The home page gives some detail about how it works and points to more 
details on my website.

Hope it 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: Variable scope for text/template

2017-10-07 Thread Simon Ritchie
AFAIK a template can only access the structure that's passed to to it.  It 
can't get at any of the other variables of the Go function that executes 
it, global or local.  All it can do is render the data in the structure 
that's passed to it.

On Friday, October 6, 2017 at 6:22:49 AM UTC+1, Hein Meling wrote:
>
> Hi all,
>
> Please see linked example code. I've been trying set a "global" variable 
> ($LastName in the example) for use inside a named template (phony in the 
> example), but the scoping rules for the template packages does not follow 
> common scoping rules typically used in other languages, including Go. And 
> it is not possible to pass more "arguments/pipelines" to the named 
> template. Any suggestions on how to accomplish something like this.
>
> https://play.golang.org/p/VjeNwr6RFe
>
> All the best,
> :) Hein
>

-- 
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] Using commercial SSL certificate with golang server?

2017-09-16 Thread Simon Ritchie
> Is there a particular directory where I should keep the certificate?

That's defined in your program.  If you write it yourself, it's up to you.

You can find a small worked example of a program that uses a certificate 
here:  https://github.com/goblimey/grpc.

Regards

Simon


On Friday, September 15, 2017 at 10:44:48 PM UTC+1, David Streckert wrote:
>
> Hey Shawn,
>
> Thank you for that. Is there a particular directory where I should keep 
> the certificate?
>
> On Friday, September 15, 2017 at 2:34:09 PM UTC-7, Shawn Milochik wrote:
>>
>> Sure. It's pretty simple:  
>> https://golang.org/pkg/net/http/#ListenAndServeTLS
>>
>> The only caveat is that you may have more than two files. If that's the 
>> case, then you will have to combine your certificate and GoDaddy's chain 
>> certificate into a single file and use that as your certificate file.
>>
>

-- 
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] if condition in html template

2017-09-13 Thread Simon Ritchie
I suggest that you use the Model View Controller pattern, which is to say, you 
do all the data processing in Go and use your HTML template only to display the 
result. For example in your Go driver program, simply create a set of strings. 
to be displayed.  For a successful backup, the string should be the HTML for 
the line containg the backup link.  For a failed backup, it's the HTML for your 
failure message.

I wrote a tool that generates a simple web server from a JSON specification 
(https://github.com/goblimey/scaffolder).  It makes heavy use of templates and 
they could have become horribly complicated.  I avoided that using this 
technique.

Fundamentally, it's much easier to write logic in Go than in templatese, and, 
of course, you can write unit tests tocheck that it works.

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

2017-09-11 Thread Simon Ritchie
> Why would someone want to switch from PostgreSQL to MySQL?

It's fairly common to use one database for production and another (often in 
memory) for testing, with an ORM hiding the differences.

-- 
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 do you test a server?

2017-07-21 Thread Simon Ritchie
My scaffolding tool generates a web server and some unit and integration 
tests.  The tests use Peter Gotz' mocking framework pegomock.  If you 
generate a server with the scaffolder, you can look at the source code and 
see how it works.

https://github.com/goblimey/scaffolder

By the way, not everybody in the Go community believes in the use of 
mocking frameworks.  Donovan and Kernighan's The Go Programming Language 
advocates a different approach.  This is used to test the entire Go 
infrastructure, so it's clearly effective.  However, I come from the London 
Java community and we use mocking frameworks a lot over here.

I used pegomock because I couldn't get gomock to work.  I managed to get 
pegomock working and I found that Peter was much more responsive when I 
reported a couple of issues with it.

For system testing, you can use the Firefox Selenium addon, which works at 
the HTTP level and doesn't care what language you used to create the 
server.  It  records a web session and produces tests in various formats, 
which you can then edit.  For example, if you record a test that creates an 
object in a database and it produced one with ID 42, and then you record a 
test that displays object 42, you can edit the test to replace the ID with 
a wildcard.

Before I wrote my scaffolder, I experimented by hand-crafting a very simple 
web server: https://github.com/goblimey/films.
I recorded some Selenium tests for this.  They are in  
tests/system/selenium.

Obviously, there is a general point here.  There are lots of tools out 
there that run penetration, performance and other types of testing on http 
servers and none of them care what technology you used to create the server.

-- 
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] filago: Monitor a Linux process' opening and closing of files, including Unix pipes and sockets

2017-06-05 Thread Simon Ritchie
Does this have some advantage over truss (or under Linux, strace)?

-- 
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 parallelize text/template long running functions?

2017-06-04 Thread Simon Ritchie
I was puzzled by something you said earlier:

> The template is the only entity that knows exactly which data from the 
data set is needed.

You've just given a bit more information, but I still don't quite 
understand.

You have some C code that you don't control and it's producing some 
information.  You have some Go which is executing a template. You say that 
the template has access to some data that the rest of the Go application 
doesn't have. 

A template is really just a function expressed in a rather opaque 
language.  The Go application invokes this function by calling the execute 
method, passing a destination and some data.  The function glues together 
the text in the template and the data, creates a piece of text and sends it 
to the destination.   While it is doing that, it can call other functions, 
so if it has a piece of data that the rest of the application doesn't have, 
it can call a function to hand it back. 

Fundamentally, the template is part of your Go application, it's just 
expressed in a cranky language that was only ever designed to describe how 
to render some text.  So I don't understand how your template can be 
holding a piece of data that the rest of the application can't get at.

That cranky language is the reason why lots of people think what you are 
doing is a bad idea.  The conventional wisdom is that a template should be 
very simple.  You should do as much processing as possible in Go before you 
call the template, and pass the results to the template as data.  Your 
application will be much easier to maintain if you do that.

Put simply, if your template code can get hold of some data, I don't 
understand why your Go code can't get hold of the same data, given that the 
template code and the Go are part of the same application.

If this is an HTTP client/server system, the template produces an HTTP 
response, perhaps some HTML, and sends to a web browser to be rendered.  
The web browser could be holding some data that the application doesn't 
have, but that's not the template, it's the client, and there are lots of 
ways to get data from a client to a server.

Can you explain the problem you have in a bit more detail?

-- 
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: $GOROOT_BOOTSTRAP variable not found if all.bash is run with sudo

2017-05-28 Thread Simon Ritchie
Your original problem was that your user didn't own the directory 
/usr/local/go1.4 or it contents.   I presume that you named it like that so 
that you could keep different versions of Go in different directories.

I do the same, but I did a little more work at the start, to save a lot of 
time later.  Do the following just once:

Create /usr/local/golang owned by your ordinary user - mine is simon, in 
group simon

- $ sudo mkdir /usr/local/golang

- $ sudo chown simon /usr/local/golang# use "chown -R" (capital R) if 
the directory already exists

- $ sudo chgrp simon /usr/local/golang  # ditto 

Once that's done, the user simon owns /usr/local/golang and anything in it, 
so that user can create Go distributions in that directory. 

As your ordinary user, create /usr/local/golang/1.4 containing Go 1.4.
Build it:

$ export GOROOT_FINAL=/usr/local/go

(The first time you do this, that directory may not exist, but that's OK.)

$ cd  /usr/local/golang/1.4

$ ./all.bash

This produces /usr/local/golang/1.4/go containing a Go distribution that 
expects to be stored in /usr/local/go.

Create a file called /usr/local/go which is a soft link to 
/usr/local/golang/1.4/go:

$ sudo ln -s  /usr/local/golang/1.4/go  /usr/local/go

$ ls -l /usr/local/go
lrwxrwxrwx 1 root root 24 May 24  2017 /usr/local/go -> 
/usr/local/golang/1.4/go


You now have a directory /usr/local/go containing a working Go distribution.

Put /usr/local/go/bin in your path.

You only have to do all that once.  From now on, to upgrade to the latest 
version of Go, do this: 

Create a directory in /usr/local/golang and put the latest distribution in 
there.  For version 1.8.3., create /usr/local/golang/1.8.3.

$ export GOROOT_FINAL=/usr/local/go

$ cd  /usr/local/golang/1.8.3

$ ./all.bash

This produces /usr/local/golang/1.8.3/go containing a Go distribution that 
expects to be stored in /usr/local/go.

Remove the soft link:

$ sudo rm /usr/local/go

and create a new one:

$ sudo ln -s /usr/local/golang/1.8.3/go /usr/local/go

(Don't do that too early in the process - you need the link to the old 
distribution to build the new distribution.)

This procedure has a number of advantages - your current version of Go is 
always called /usr/local/go, you don't have to run many commands as root 
and the process of upgrading to the next version is reasonably simple.

-- 
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] scaffolder - web application servers to order

2017-05-15 Thread Simon Ritchie
Don't wait.  Write it yourself.

Seriously, if my solution does most of what you want, but it's not quite
right, it's very easy to change it.  Just hack the templates.

Regards

Simon

On Mon, May 15, 2017 at 4:41 PM, Tong Sun <suntong...@gmail.com> wrote:

> Quite agree with the following.
>
> scaffolding just like symfony/RoR scaffold generator! That's something I
> had been hoping and looking for for quite a while.
>
> Thanks a lot!
>
>
> On Thursday, May 11, 2017 at 4:37:44 AM UTC-4, mhh...@gmail.com wrote:
>>
>> It s awesome,
>> in my opinion, this is the way i want to consume go in the future.
>>
>> pragmatic, correct, fast, repeatable.
>>
>> in additions to what go provides,
>> fast build, cross platform, easy to package
>>
>> Although, my very personal opinion,
>> lets do smaller program that combines together,
>> in the spirit of unix tooling, rather than a
>> big boiler plate thing in the spirit of symfony
>> or alike (really just an example sorry i cited your project).
>>
>> A big Yes for such projects!
>>
>> Let s generate all the thing and get drinks to talk about it :D
>>
>> PS: i remember you talked about it earlier, shame i missed it at that
>> time.
>>
>> On Wednesday, May 10, 2017 at 6:31:22 PM UTC+2, Simon Ritchie wrote:
>>>
>>> Given a JSON description of some database tables, the scaffolder tool
>>> creates the database and generates a web application server to manage it.
>>> The resulting app server implements the Create, Read, Update and Delete
>>> (CRUD) operations on the tables.
>>>
>>> The idea for the scaffolder comes from the Ruby-on-Rails scaffold
>>> generator.
>>>
>>> The app server is presented as Go source code and HTML templates, plus
>>> some unit and integration tests.  The design follows the Model, View
>>> Controller (MVC) pattern.  The HTTP requests follow the REST pattern.
>>>
>>> The tool is here:  https://github.com/goblimey/scaffolder
>>>
>>> There are some screen shots of the resulting web pages here:
>>> http://www.goblimey.com/scaffolder/2.4.running.the.server.html
>>>
>>> Producing any web application involves a lot of boilerplate work, and
>>> this tool aims to automate some of that without imposing too many design
>>> decisions on the result.
>>>
>>> The generated web pages are fairly primitive, with very little styling.
>>> This is deliberate - if you want to use the result as a basis for building
>>> your own application, you will want to define your own styling, and the
>>> pages are structured to allow that.
>>>
>>> The material produced by the scaffolder is defined by a set of text
>>> templates.  For each table it produces from these templates a model, a
>>> controller and set of HTML templates to produce the views.  (So we have
>>> templates producing templates.)
>>>
>>> The scaffolder tool itself is very simple.  It just reads the JSON
>>> specification into a data structure, enhances that data a little and then
>>> iterates through it, supplying it to the templates.   This approach makes
>>> the tool very flexible - if it doesn't do quite what you want, it's very
>>> easy to tweak it.
>>>
>>> This idea of using a simple driver program, JSON data and templates to
>>> generate a result is very powerful.  It can be used to produce all sorts of
>>> material that follows a prototypical pattern.
>>>
>>> All comment on this project are welcome.
>>>
>> --
> 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/_WxygmYF1F8/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] Java to Golang converter

2017-05-12 Thread Simon Ritchie
I think the problem is testing.  If you use a tool to convert one language to 
another, you have to check that the result works, which involves a lot of 
testing, possibly as much as you had to do to get the original working in the 
first place.  So it's expensive.

It will usually be cheaper to leave your original Java in place, writie new 
functionality in Go and integrate the two together.   You can do that using web 
services, gRPC, a Service Bus or whatever.

This is pretty much the way that Java replaced COBOL.  A common trick in the 
beginning was to put a layer of Java in front of a COBOL solution to provide a 
web interface.  Extra functionality could then be written in Java.  Some of 
those COBOL solutions are still running, hiding behind a Java app.

-- 
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] scaffolder - web application servers to order

2017-05-11 Thread Simon Ritchie
> PS: i remember you talked about it earlier, shame i missed it at that
time.

I've given a couple of talks that mention the scaffolder.  One was recorded
for posterity.  It was to the Linuxing in London meetup and it was about
running Go on a single board computer.  I used the scaffolder as an
example:  https://skillsmatter.com/skillscasts/9622-go-lang-on-linux

Regards

Simon

On Thu, May 11, 2017 at 9:37 AM, <mhhc...@gmail.com> wrote:

> It s awesome,
> in my opinion, this is the way i want to consume go in the future.
>
> pragmatic, correct, fast, repeatable.
>
> in additions to what go provides,
> fast build, cross platform, easy to package
>
> Although, my very personal opinion,
> lets do smaller program that combines together,
> in the spirit of unix tooling, rather than a
> big boiler plate thing in the spirit of symfony
> or alike (really just an example sorry i cited your project).
>
> A big Yes for such projects!
>
> Let s generate all the thing and get drinks to talk about it :D
>
> PS: i remember you talked about it earlier, shame i missed it at that time.
>
> On Wednesday, May 10, 2017 at 6:31:22 PM UTC+2, Simon Ritchie wrote:
>>
>> Given a JSON description of some database tables, the scaffolder tool
>> creates the database and generates a web application server to manage it.
>> The resulting app server implements the Create, Read, Update and Delete
>> (CRUD) operations on the tables.
>>
>> The idea for the scaffolder comes from the Ruby-on-Rails scaffold
>> generator.
>>
>> The app server is presented as Go source code and HTML templates, plus
>> some unit and integration tests.  The design follows the Model, View
>> Controller (MVC) pattern.  The HTTP requests follow the REST pattern.
>>
>> The tool is here:  https://github.com/goblimey/scaffolder
>>
>> There are some screen shots of the resulting web pages here:
>> http://www.goblimey.com/scaffolder/2.4.running.the.server.html
>>
>> Producing any web application involves a lot of boilerplate work, and
>> this tool aims to automate some of that without imposing too many design
>> decisions on the result.
>>
>> The generated web pages are fairly primitive, with very little styling.
>> This is deliberate - if you want to use the result as a basis for building
>> your own application, you will want to define your own styling, and the
>> pages are structured to allow that.
>>
>> The material produced by the scaffolder is defined by a set of text
>> templates.  For each table it produces from these templates a model, a
>> controller and set of HTML templates to produce the views.  (So we have
>> templates producing templates.)
>>
>> The scaffolder tool itself is very simple.  It just reads the JSON
>> specification into a data structure, enhances that data a little and then
>> iterates through it, supplying it to the templates.   This approach makes
>> the tool very flexible - if it doesn't do quite what you want, it's very
>> easy to tweak it.
>>
>> This idea of using a simple driver program, JSON data and templates to
>> generate a result is very powerful.  It can be used to produce all sorts of
>> material that follows a prototypical pattern.
>>
>> All comment on this project are welcome.
>>
> --
> 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/_WxygmYF1F8/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] [ANN] scaffolder - web application servers to order

2017-05-10 Thread Simon Ritchie
Given a JSON description of some database tables, the scaffolder tool 
creates the database and generates a web application server to manage it.  
The resulting app server implements the Create, Read, Update and Delete 
(CRUD) operations on the tables.

The idea for the scaffolder comes from the Ruby-on-Rails scaffold generator.

The app server is presented as Go source code and HTML templates, plus some 
unit and integration tests.  The design follows the Model, View Controller 
(MVC) pattern.  The HTTP requests follow the REST pattern.

The tool is here:  https://github.com/goblimey/scaffolder

There are some screen shots of the resulting web pages here:   
http://www.goblimey.com/scaffolder/2.4.running.the.server.html

Producing any web application involves a lot of boilerplate work, and this 
tool aims to automate some of that without imposing too many design 
decisions on the result.  

The generated web pages are fairly primitive, with very little styling.  
This is deliberate - if you want to use the result as a basis for building 
your own application, you will want to define your own styling, and the 
pages are structured to allow that.

The material produced by the scaffolder is defined by a set of text 
templates.  For each table it produces from these templates a model, a 
controller and set of HTML templates to produce the views.  (So we have 
templates producing templates.)

The scaffolder tool itself is very simple.  It just reads the JSON 
specification into a data structure, enhances that data a little and then 
iterates through it, supplying it to the templates.   This approach makes 
the tool very flexible - if it doesn't do quite what you want, it's very 
easy to tweak it.

This idea of using a simple driver program, JSON data and templates to 
generate a result is very powerful.  It can be used to produce all sorts of 
material that follows a prototypical pattern.

All comment on this project are welcome.

-- 
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: Should we use frameworks like Go IRIS based on fasthttp to create foundation of my web application or do I start create framework from scratch

2017-05-05 Thread Simon Ritchie
A web framework that matches what you want to do will save you time.  The 
trick is to spend less time evaluating frameworks than you save by using 
one.

You could try mine.  It's very simple, produces some useful basic stuff and 
doesn't force too many decisions onto you:  
https://github.com/goblimey/scaffolder


-- 
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] "Selling" Go to Management

2017-05-02 Thread Simon Ritchie
I think interoperability is an important issue.  If you are trying to introduce 
Go into a mature environment you need to avoid any idea that the existing apps 
will have to be rewritten.

For example, gRPC allows a Go application to work with apps written in Java, 
C#, RoR, Python and a host of other languages, so it offers the potential to 
introduce new functionality written in Go and make it work with the stuff that 
you already have.

Another issue is testing.  Go has excellent ready-made testing facilities.  
However, not all managers understand how important testing is, so that point 
may be irrelevant to your purposes.

In general, when dealing with managers, talk about money - you need to argue 
that Go offers lower development costs, better software for the same money, 
more efficient use of equipment, and so on.  If you can't offer those benefits 
convincingly, they probably won't be interested.


-- 
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: x509.Certificate.Verify: "x509: certificate signed by unknown authority"

2017-04-20 Thread Simon Ritchie
Are you trying to figure out why this happens, or do you just want a 
self-signed certificate that works with Go?  

Assuming that you want to generate a working certificate, I did some work 
in this area a few weeks ago and encountered problems..  I found some 
instructions via Google for creating a self signed certificate.  It didn't 
work with Go, although the error I got was different from the one you got.  
I then found a Go utility that generated a certificate that works.

I've written a version of the gRPC hello world example that uses a secure 
connection using this certificate: https://github.com/goblimey/grpc.  
There's a comment in my code:

// To make the connection work you need a self-signed certificate and a
// matching private key.  Create these using lc-tlscert:
//
//go get github.com/driskell/log-courier
//go install github.com/driskell/log-courier/lc-tlscert
//lc-tlscert
//(Give your server name as the common name)
//
// The common name must match the server name that the client will use 
to
// connect.  If the client and server are on the same machine you can 
use
// "localhost".


If you are trying to figure out the cause of the problem, then a working 
example might help with that too.

Regards

Simon

-- 
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 do I test an func which depends on (pseudo)-random numbers, e.g. rand.Intn()?

2017-03-16 Thread Simon Ritchie
As some posters have already said, it depends what you are trying to test.  

If you want to test what your solution does when it receives a 
randomly-generated number, then you don't need to use random numbers.  You can 
hide the generation of the random number in a type which is defined by an 
interface.  Then you can supply a dummy version of the type which supplies 
numbers that you choose specifically for your test.  So for example, if you 
want to test what your solution does when it receives a randomly-generated 
number less than 10, you set up a test that supplies it with 8.

On the other hand, if you want to test the random number generator, for example 
to test its randomness, then this approach is no good.

Simon

-- 
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 pass value in nested template if possible?

2017-03-14 Thread Simon Ritchie
You are right, the documentation for templates is very scanty.  You will find 
all sorts of useful examples in my scaffolder project 
https://github.com/goblimey/scaffolder.

This doesn't answer your main question, but I see that somebody else has done 
that.

Simon

-- 
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] gRPC, OAUTH and TLS in Go part 1 - gRPC and TLS

2017-03-07 Thread Simon Ritchie
I'm working on a solution that involves a gRPC connection authenticated 
using OAUTH.

I pretty quickly discovered several things:

- gRPC will not allow you to use OAUTH over an http connection.  You must 
use an https connection.

- There is quite a lot of infrastructure involved

- There are lots of hints out there about how to do all this, but I 
couldn't find any worked examples.

The first of those points is obviously sensible.  To use OAUTH you put a 
token into the authorization header of each gRPC request.  You use the same 
token for many requests,  so if you use an http connection, somebody could 
easily intercept your requests, copy your OAUTH token and create fake 
requests of their own.  You need to send the traffic over an encrypted 
connection to prevent that.

However, this has a side effect:  you can't get anywhere with gRPC and 
OAUTH until you have got your HTTPS connection running, and that takes a 
bit of work.

So, my first worked example shows how to run gRPC over HTTPS and how to 
generate the necessary keys and certificate to make that work.  It's a 
reworked version of Google's helloworld greeter server, which uses an http 
connection.  The readme explains all the gory details and there are 
comments in the source code.  https://github.com/goblimey/grpc

Now I will go away and get the OAUTH bit working.  Once I've got that done 
I will post part 2, but I'm doing this in my spare time, so don't hold your 
breath.

Simon

-- 
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: Load public key from DER encoded certificate

2017-03-07 Thread Simon Ritchie
I've just put onto github a working example of an application that loads 
and uses a digital certificate.  It's not DER, but the code is probably a 
good guide as to what you need to do:  https://github.com/goblimey/grpc

I hope this helps.

Simon


-- 
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: Bots on the mailing list

2017-03-05 Thread Simon Ritchie
> Apparently they're all "yahoo" email addresses.

Very few organisations supply free email addresses these days, pretty much 
only Google and Yahoo.  A few years ago the project I was working on needed 
a constant supply of new email addresses for testing.  They had to be real 
working email addresses.  I pretty quickly discovered that  to create a 
Google account and thus get a gmail address you have to give a working 
mobile phone number and you are only allowed ten accounts per phone 
number.  Yahoo on the other hand doesn't require any secondary contact 
information so you can create as many accounts as you like.  I ended up 
creating about 100 accounts to test my system..

So if somebody is pulling some sort of scam and needs to create a few 
thousand convincing-looking email addresses, Yahoo is their supplier of 
choice.

Having said that, my lawyer reminds me that I should not suggest for one 
moment that there is anything fishy about the addresses you mention.  I'm 
sure that whoever created them is pure as the driven snow.

Regards

Simon

>
>

-- 
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] two new google groups for the UK Go community

2017-02-26 Thread Simon Ritchie
I've just created two Google groups for the UK Go community.

The group golang-uk is for discussions about Go that are mainly of interest 
to people in the UK.  Go is Go wherever you are, so I don't expect this 
group to carry many technical discussions, if any.  I envisage that its 
main use will be to advertise UK Go meetups and events such as the Golang 
UK conference which is scheduled for August:  http://golanguk.com/

There are a few Go user groups around the UK organising local meetups.  I'm 
one of the organisers of the Surrey Go User Group and we are finding it 
very hard work to make ourselves known.  It looks like most other user 
groups have the same problem, which is why I set up the golang-uk group.

One way for potential members to find out about local user groups is the 
list held on the Golang Wiki page 
https://github.com/golang/go/wiki/GoUserGroups but you need to know about 
that to use it.

Until now the main way we have promoted our group has been the meetup.com 
website, but that audience is a bit limited.  Also, it costs $120 a year to 
advertise meetups on that site.  For somebody who just wants to get 
together with a few like-minded people to discuss Go, a Google group is 
more practical.  

I've already found and contacted the Go meetups in London, Edinburgh, 
Cardiff, Manchester, Cambridge and Suffolk.  Some of the organisers have 
already joined the group and I hope that the rest will.  I've also seen 
traces on Google of people trying to set up a group in Hampshire, but I 
haven't been able to contact them yet and I'm not sure how far they have 
got.  If you know of any UK meetups that I've missed, please get them to 
announce themselves on golang-uk.

The second group golang-uk-jobs is for advertising UK jobs involving Go.  

Go is taking off slowly but steadily in the UK.  One rough measure of this 
is the number of jobs advertised on the website jobserve.com .  (Jobserve 
is the most popular UK website for advertising IT jobs.)  Over the last 
seven days there have been 26 permanent jobs advertised mentioning Golang, 
plus two contract roles.   To put that  into perspective, over the same 
period there were 1,113 ads for perm jobs using Java, and 453 contract 
roles.  However, when I did a similar trawl a year ago, there were no Go 
jobs advertised.
  
Jobserve only gives a rough measure of activity.  Some jobs are advertised 
several times and some are not advertised at all - the UK Go community is 
small enough that some employers recruit through word of mouth.  The Go 
London User Group often has a short hiring fair at the end of its 
meetings.  The golang-uk-jobs group gives people another way to recruit 
directly.

To avoid the jobs group being flooded with get-rich-quick schemes and other 
scams, all posts are moderated, so traffic should be light and relevant.  
Assuming that Go continues to grow, a mailing list will eventually become 
unwieldy, but we will cross that bridge when we come to it.

I think that it's the right time for these groups and I hope that people 
will find them useful.

-- 
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: first try with templates

2017-02-26 Thread Simon Ritchie
Sorry, that last response could have been a bit more helpful.

My templates take a structure as input.  When I execute the template, I 
pass the structure to the template.  

This line in the template:

{{$resourceNameLower := .NameWithLowerFirst}}

takes the contents of the NameWithLowerFirst field of the input structure 
and creates a variable resourceNameLower.

Extract  the contents of the variable like so:

{{$resourceNameLower}}

I hope that helps.

Regards

Simon

-- 
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: first try with templates

2017-02-26 Thread Simon Ritchie
The documentation for Go templates is ... scanty.

My scaffolder https://github.com/goblimey/scaffolder includes several 
templates that set variables.  It does other useful stuff such as driving 
template production from a JSON spec, creating templates from other 
templates, and so on.

Regards

Simon

-- 
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] JSON parser

2016-11-10 Thread Simon Ritchie
I'm also not sure what you are trying to do.  However, I think I can see a bug 
in your code.

First you run a database query to get a list of values from a field called 
data.  This could produce up to 10 values.

Next you have a loop which runs through the values and discards them.  At the 
end of the loop, you have the data field from the last record, and you have 
thrown away all the others.  Is this what you want?

Finally, you unzip the last data field.

So if your table contains 100 records, you will get 10 of them, throw away the 
first 9 records and unzip the data from the last one.

I 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: With GO - Can I say Procedural is better than OO?

2016-11-05 Thread Simon Ritchie
> Can I say Procedural is better than OO?

Better at what?  It depends what you are trying to do.

The novelist and aeronautical engineer Neville Shute wrote "It has been 
said an engineer is a man who can do for five shillings what any fool can 
do for a pound".

These days we accept that some engineers are women, but the point still 
holds.  You should use whatever technique gets you the result you need and 
does it for the least cost.  That could be an object-oriented Go solution, 
a procedural Go solution, a shell script, a spreadsheet, an abacus or one 
of many other choices.  

My only caveat is that when you consider cost, you need to think about the 
whole life of the project.  if you are going to use a solution for years, 
there's no point producing a quick and dirty version that doesn't work 
properly.

As for the discussions in this thread about Go's object oriented model 
compared with those offered by other languages, I'm reminded of Bjarne 
Stroustrup's paper "What is Object-Oriented Programming?", published around 
the time he was creating C++.  I don't have my copy to hand, but he pointed 
out that you can write an object-oriented program using any programmable 
system, from a Turing machine upwards.  The important issue is, does the 
system support Object-Oriented Programming rather than merely allowing it.

As fa I'm concerned, Go supports Object-Oriented Programming at least as 
well as any other language that I know, and a lot better than most of them.

-- 
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: Trying to understand GOPATH

2016-09-24 Thread Simon Ritchie
This could be a bit better explained on the golang website.  

First, note that there are potentially three environment variables 
involved: PATH; GOROOT and GOPATH.

The Getting Started guide (https://golang.org/doc/install#install) gives 
quite a lot of help, and you should read that thoroughly.  Firstly it says:

"The Go binary distributions assume they will be installed in /usr/local/go 
(or c:\Go under Windows), but it is possible to install the Go tools to a 
different location. In this case you must set the GOROOT environment 
variable to point to the directory in which it was installed."

So, you either install the tools in the default location or you set GOROOT.

If you have this include:

include ("log")

Then the compiler can find the log package in either the default location 
or the one in GOROOT.  

My Go installation is in the default /usr/local/go, so my log package is in 
/usr/local/go/pkg/linux_amd64/log.a.  The source code is in 
/usr/local/go/src/log.

I set up my .profile to put /usr/local/go/bin into my PATH, so I can run 
the go tools.

Assume that I set the GOPATH variable like so 

export GOPATH="/home/simon/gocode:/home/simon/goprojects/films"

and I run

go get github.com/emicklei/go-restful

This fetches the go-restful package and puts it into THE FIRST directory in 
the GOPATH.  So now I have

/home/simon/gocode/src/github.com/emicklei/go-restful/

containing the source code and

/home/simon/gocode/pkg/linux_amd64/github.com/emicklei/go-restful.a 

containing the compiled object

I can now have this include

include github.com/emicklei/go-restful

My own project lives in the second directory in the GOPATH - 
/home/simon/goprojects/films.  As  Volker explained, this should contain a 
directory src containing the source code.  When I run the compiler, it will 
create directories pkg and bin.

The Getting Started guide goes on to explain how to create source code that 
you can commit to the github.  "Next, make the directories 
src/github.com/user/hello inside your workspace (if you use GitHub, 
substitute your user name for user), and inside the hello directory create 
a file named hello.go"

In fact, if you are going to commit your project to the github, then you 
should create an empty project on github.com first and then clone it on 
your machine.  This creates a directory for you, an empty git repository.  
It contains a "hidden" directory .git containing all the information that 
git needs to work.  When you have everything working, you can commit your 
files and push them to the github.

For example, I have a github account goblimey and I used the github.com 
website to create a project called films.  I then did this on my machine:
  
cd /home/simon
mkdir goprojects
cd goprojects
clone https://github.com/goblimey/films  # creates a directory films

export GOPATH="/home/simon/gocode:/home/simon/goprojects/films"
export 
PATH=$PATH:/home/simon/gocode/bin:/home/simon/goprojects/films/bin

So now I have a github repository in the directory films and the two bin 
directories are in my PATH.  One of the bin directories doesn't exist yet, 
but the first compilation will create it.

In the films directory I create src/github.com/goblimey/films.  My source 
code lives in there.  

So, I end up with 
/home/simon/goprojects/films/src/github.com/goblimey/films containing my 
source code.

To install it, I use this command (which I can run from any directory)

go install github.com/goblimey/films

This looks through the directories in my GOPATH looking for one that 
contains src/github.com/goblimey/films and compiles the contents.

The result goes into /home/simon/goprojects/films/pkg and 
/home/simon/goprojects/films/bin.

Given any include, the compiler will search for it in either the default 
compiler location or GOROOT, plus the directories in GOPATH.  In my case, 
that will be:

/usr/local/go/pkg
/home/simon/gocode/pkg/linux_amd64
/home/simon/goprojects/films/pkg/linux_amd64

Once I have everything working, I commit the result to the github BUT not 
the bin or pkg directories.  Only the src directory.  That gives enough 
information for somebody to clone my project and build it themselves.  
Their bin and pkg directories will be different from mine, so we don't want 
them in the repository.  (In general, if file B is created from file A, put 
A into the repository but not B.)

The scheme I use allows me to have Go projects in different directories.  
That requires a different GOPATH setting for each one, so I create a script 
in each project directory that sets up the GOPATH.

If you want to, you can put just a single directory in your GOPATH.  In 
that case, it will contain everything that you fetch using go get and 
everything that you create yourself.  I prefer to keep things separate.

To sum up, this issue is really quite a complicated.  You need to read the 
documentation carefully, but there are gaps in 

[go-nuts] Re: Handling multiple things happening at the same time

2016-09-10 Thread Simon Ritchie
> maybe gocron can schedule the http.ListenAndServe to run all the time?

The classic solution (which is how the Apache web server does it) is to 
have a shell script that loops forever, starting the web server, waiting 
for it to finish and starting it again.  So, if the server crashes, the 
parent script starts it again.  You set the starter script up so that it is 
kicked off when the machine starts up.

It sounds like this just moves the problem to the parent script, but 
actually that doesn't do very much, so it's much easier to make it (almost) 
never crash.

The problem then is to make the server stop when you need it to.  That's 
achieved by making the parent script a signal catcher.  One signal makes it 
kill its child and then stop.  Another makes the child reread its 
configuration files and reconfigure itself.  You have another script that 
sends the signals - the stop script.  You include a call to this in the 
stuff that is run when the machine shuts down, so the web server is shut 
down tidily.

To get all that to hang together, the first parent script records its PID 
in a file when it starts.  The stop script reads the PID from the file.

You could do worse than downloading Apache and stealing the startup and 
shutdown scripts.  They've been in use for twenty years or more, so they 
are now fairly robust.

>
>
>
>
>
>
>

-- 
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: Handling multiple things happening at the same time

2016-09-10 Thread Simon Ritchie
I agree with Asit, but I would go further.  You have one thing that is 
fetching files and putting them in a directory.  You have another thing 
that is exposing the files in a directory via a web interface.  Except that 
they happen to be working on the same directory, there is no connection 
between the two things.  They could run on different machines.  My 
suggestion would be to have two completely separate programs.  Then, 
assuming that the machine(s) they run on stay up, if the file fetcher falls 
over, the web server will still display the files that are there, and 
vice-versa.

I did similar things during a project I worked on a couple of years ago, 
but not using Go.  That solution uses a Java web server to display data 
which is fetched using an off-the shelf FTP server driven by cron scripts 
running TCL programs.  We authenticated the FTP connection using passwords 
and I recall that one of the challenges was to protect the password from 
exposure.  You could probably cobble together a prototype file fetcher more 
quickly using a solution like that, but it would be easier to make a Go 
solution secure.  

For maximum security, use certificate authentication rather than passwords, 
but that involves passing certificates around, which can delay getting the 
thing up and running, especially if there are lots of organisations 
providing the files.

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


[go-nuts] Re: How to build mock class?

2016-09-07 Thread Simon Ritchie
I think your problem is this:  You have a piece of code that uses a class.  
You have two classes, one real, one mock and you want to write some client 
code that can use either of them.  Is that right?

If you want to use mocking, you must write your classes in the appropriate 
way, so you may need to rework your solution.

There is an example of mocking in Donovan and Kernighan on page 309.  They 
show a function that uses a object called out that is an io.Writer.  The 
io.Writer is an interface and there are a number of structures (classes) 
available that satisfy it.  The out object is created outside the function 
that's being tested, so client code doesn't know what out is, it just knows 
that it satisfies the io.Writer interface.  The real application supplies 
an io.Writer that writes to the standard output channel and the test code 
supplies a different io.Writer which it can examine at the end of the test.

Another way to achieve the same effect is to pass the object into the 
function as a parameter, and declare the parameter as an interface.

So, if you are going to mock your class, you need to create an interface 
that the class satisfies.  In go, you can create the interface, and then 
create the structure, or you can create the structure and add the interface 
later.  Your structure MyClass has two methods, so you could write this 
interface:

type MyClass interface {

Object() (int)

PrintInfo()
}

Then rename your structure RealMyClass and create another one MockMyClass.  
Both should have methods object() and PrintInfo(), so they both satisfy the 
MyClass interface.  Write the code that uses the class so that it only 
knows that it is uses a MyClass.  

Essentially, you have three pieces of code, (a) a function that uses a 
class, which is the piece that you are going to test, (b) some code that 
tests (a) and (c) some code in your real application that uses (a).  (b) 
and (c) must both create a class that satisfies the interface and then call 
the function (a), supplying that class.  In your case, (b) would create a 
MockMyClass and (c) would create a RealMyClass.  (a) only knows that it is 
receiving a MyClass.

Small problem: you can't have two pieces of code in the same package with 
the same public methods, so you have to put RealMyClass and MockMyClass in 
different packages, ie in different directories.  I would put the interface 
and RealMyClass in the same package and create a separate directory 
structure for my mocks.

Bigger problem: an interface can only describe the class methods, so 
whatever the calling code needs to do, it must do it by calling class 
methods.  In your case, your client code can call PrintInfo() and 
Object().  This is why you may need to rework your code.

It's only possible to mock well-behaved structures.  A good example of 
something that can't be mocked is getting the URL from the Request object 
of the net/http package.  Request has a public field called URL.  If you 
have a Request object called request and you want to get hold of the URL 
embedded in it, you do this:

request.URL

That's not a call to a method, so you can't write an interface that 
describes this.  Request has some class methods, so you can create an 
interface that it satisfies, but that interface can't describe the 
behaviour of extracting the URL.  A function that's not a class method is 
another example of something that can't be mocked.

In other words, to support mocking, you must design your classes from the 
start so that they can be used through interfaces.

That's not to say that your real structures can't have public fields or 
functions that are not methods.  It's just that the code that you are going 
to test can't use them.  The piece that creates the object knows what it 
really is - a MockMyClass or whatever - so it can use its extra public 
fields and so on.  Only (a) has to work through the interface.  So, your 
mock object may have all sorts of extra features that allow the test code 
to extract useful information from it, and those don't need to be described 
by the interface.

You can create your own mock classes, but there are a number of frameworks 
that will create mocks to order for you.  This is one, and the home page 
includes a survey of others that are available:  
https://github.com/petergtz/pegomock.

A mocking framework creates a general-purpose mock object that can be 
controlled at runtime.  At the start of your test, you can say things like 
"when object() is called for the first time, return 3, and when it's called 
for the second time, return 2".  At the end of the test you can say 
something like "check that object() was called exactly twice".

Some people think that these mocking frameworks are unnecessary, or even a 
bad idea.  Certainly, it takes a bit of time to figure out how they work.  
My attitude is, you can use a mock that you create yourself or you can 
generate one using one of these frameworks, and you should use 

[go-nuts] Re: on GOPATH

2016-09-02 Thread Simon Ritchie
Responses to a question like this tend to be either very detailed, or 
vague.  This one has all the gory details.

I develop under Linux.  I'm happy to use fancy visual tools, but I also do 
a lot of stuff from the command line.

I have a directory GOCODE where I put stuff that I fetch via go get.  I set 
this up In my .profile, and put the bin directory in my path along with the 
Go bin directory:

GOPATH=$HOME/gocode
export GOPATH

   PATH=/usr/local/go/bin:$HOME/gocode/bin:$PATH
export PATH

(Under Linux you can create a variable and export it in one command, but 
that doesn't work across all UNIX systems.)

You may want to include your go tools bin directory in the path as well.

With this .profile, once I'm logged in, I have a GOPATH variable containing 
my gocode directory.

I keep each of my Go projects in a separate directory.  In the top level 
directory of each project I create a file setenv.sh containing this:

if test -z $GOPATH
then
GOPATH=`pwd`
export GOPATH
else
GOPATH=$GOPATH:`pwd`
export GOPATH
fi

PATH=`pwd`/bin:$PATH
export PATH


That notation `pwd` in grave accents, means the current directory, so I can 
just copy this file from one project to another and it will work, as long 
as you run it from the right directory.

To set up GOPATH for a project, I start a command window, change directory 
to the project and run the commands in setenv.sh:

.  setenv.sh

(Note the "." at the start - see later about that.)  If GOPATH doesn't 
already exist, it's created and contains just the current directory.  If it 
exists, the current directory is added.  Then the local bin directory is 
added to my path.  YOU NEED TO BE IN THE RIGHT DIRECTORY, the top level of 
your project (the one that contains src, pkg, bin etc.)

For example, if my project is $HOME/project1 and my .profile is set up as 
above, then GOPATH would contain something like

/home/simon/gocode:/home/simon/project1

Now the go command can find my project and anything I've downloaded via "go 
get".

My PATH variable will contain

/home/simon/project1/bin:(whatever was already in the path)

so any command that I build within this command window is in my path.  In 
my .profile I set up the path to include the go and gocode bin directories, 
so that stuff is in my path too.

Strictly, I don't need the setenv.sh file.  I could just cd to the right 
directory and run this command by hand:

GOPATH=$GOPATH:`pwd`

As long as you cd to the right directory first.  In fact the main purpose 
of creating the setenv.sh files is to remind me which directory I should be 
in when I run the commands! 

If GOPATH contains a colon-separated list of directories as above, "go get" 
uses the first one in the list.  In my case that will always be my gocode 
directory, because I set it up that way in my .profile, and my setenv.sh 
files ensure that it's kept as the first directory.  That means I can run 
"go get" in any command window and it will always put stuff in the same 
place.

If I run a tool such as liteide from my command window having run 
setenv.sh, it picks up the GOPATH that I set up.

If you use an IDE (liteide, eclipse, intellij or whatever) then you can 
simply set up a local GOPATH variable in the ide.  The technique I describe 
above is not quite so slick, and depends upon you remembering to run the 
commands in setenv.sh before you start working, but if you still want the 
option of running commands from a command window, you need something like 
this.

A note for people who are not Linux shell experts:   setenv.sh looks like a 
shell script, but it isn't.  If you ran it as a shell script it wouldn't 
work.  Any variables that a shell script set up are lost when the shell 
script ends, so your script would set up GOPATH and then discard it.  You 
need to run setenv.sh using the "." command as above.

I've used all sorts of UNIX magic here - shell if commands, running 
commands in grave accents, running commands using "." and so on.  If you 
are working under Windoze, none of this will work, but you can do similar 
stuff using batch files.

-- 
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: totalling a column in a html template.

2016-08-26 Thread Simon Ritchie
If you follow the Model View Controller (MVC) model, you should do all of the 
clever stuff in your controller and just use the view to render the result.

When you invoke the view, you pass a structure with it contains the data to 
display.  The trick is to design your structure to contain all the data that 
the views needs.  In your case that might be a structure containing a total and 
a slice containing numbers.  In the view you iterate through the slice 
displaying each number, and then display the total.  If you want several 
columns then you might pass a structure containing a total and a slice of 
structures, where each structure contains the values for one row.

Another typical example of this kind of thing is a page that contains some 
validated data with error messages.  In that case, your structure would contain 
the data and the error messages.

-- 
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] Simple test runner

2016-08-12 Thread Simon Ritchie
> go test ./...

Sorry, I should have said, I already tried that.  The problem is, if you
have any directories that don't contain any tests, you get complaints.  For
each directory with no test files, you get a line on  stdout containing "?"
and "[no test files]".  This includes directories that just contain other
directories.  I could just ignore those complaint lines in the output, but
I prefer not to ignore complaint messages - it's easy to miss a similar
complaint that matters.

So, I'm looking for something that only runs "go test" in directories that
contains tests.

On Fri, Aug 12, 2016 at 7:28 AM, Dan Kortschak <
dan.kortsc...@adelaide.edu.au> wrote:

> go test ./...
>
> On Thu, 2016-08-11 at 23:22 -0700, Simon Ritchie wrote:
> > Is there a simple tool that will search for and run all the tests in a
> Go project?
> >
> > What I'm looking for is a tool that will start at a given directory and
> descend recursively through any subdirectories, looking for test files and
> running them using go test.  Under UNIX you can do this using  find, but
> some people develop under Windoze.  You can do it using make, but then you
> have to maintain a make file.  The tool I describe would be
> self-maintaining.
> >
> > If such a tool does not exist, I plan to write one, but I thought I
> would ask first.
> >
> > Just to clarify, I'm not
> > looking for some fancy all-singing-all-dancing test management
> framework.  I just want a simple way to run all my tests.
>
>
>

-- 
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] Simple test runner

2016-08-12 Thread Simon Ritchie
Is there a simple tool that will search for and run all the tests in a Go 
project?  

What I'm looking for is a tool that will start at a given directory and descend 
recursively through any subdirectories, looking for test files and running them 
using go test.  Under UNIX you can do this using  find, but some people develop 
under Windoze.  You can do it using make, but then you have to maintain a make 
file.  The tool I describe would be self-maintaining.

If such a tool does not exist, I plan to write one, but I thought I would ask 
first.

Just to clarify, I'm not 
looking for some fancy all-singing-all-dancing test management framework.  I 
just want a simple way to run all my tests.

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


[go-nuts] Re: How to create reusable HTML components using default html/template package

2016-08-08 Thread Simon Ritchie
> Specifically, is there a recommended pattern on how to use a component 
inside another component inside another component passing data to each one 
in a transparent way?

That's not awfully specific.  I'm guessing that you are thinking of a 
particular framework that you have used with another language.  Can you say 
what that is?  Your question would be clearer if you do that.

I'm using a solution based on ideas from Struts and Spring, which are Java 
frameworks.  However, what I'm doing may not be anything like what you are 
trying to do.

-- 
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] problem with -import in gomock

2016-08-07 Thread Simon Ritchie
 

I'm having a problem with the -import mechanism in mockgen. I opened an 
issue on the gomock github page five days ago, but nobody has responded.


I'm using gomock to generate static mocks.  One of my generated mocks is 
throwing a syntax error.  To fix this, I'm trying to set the name of a 
package which the mock is importing. I can't figure out how to do it.


When I create my mock with mockgen, it contains this import:


person "github.com/goblimey/films/models/person"


The mock includes this method.  The syntax error is on the line that I've 
marked with a comment:


func (_m *MockDAO) Create(person person.Person) (person.Person, error) {
ret := _m.ctrl.Call(_m, "Create", person)
ret0, _ := ret[0].(person.Person)// syntax error here
ret1, _ := ret[1].(error)
return ret0, ret1
}


The error is:


./MockDAO.go:76: person.Person undefined (type person.Person has no field 
or method Person)


This is caused by confusion between the variable person and the package 
person. I need the import line to be something like:


import (
personModel "github.com/goblimey/films/models/person"


So the import is called personModel, not person.


According to the documentation I can fix this problem using -import when I 
run mockgen. However, when I do that, I still get the import line that 
provokes the error. 


In this example, I run the command and display the first ten lines that it 
produces:


$ mockgen -package mocks -source ../daos/people/DAO.go \
-imports 'personModel=github.com/goblimey/films/models/person' 
| head -10
// Automatically generated by MockGen. DO NOT EDIT!
// Source: ../daos/people/DAO.go

package mocks

import (
person "github.com/goblimey/films/models/person"
dbsession "github.com/goblimey/films/utilities/dbsession"
gomock "github.com/golang/mock/gomock"
)



Does anybody know how to make the -import flag of gomock do what I need?


(For the benefit of IDE lovers:  the first line iin the example s a command 
that I type into a terminal window.  The rest is the response.)


(For the benefit of MS Windows users, this is a UNIX command.  I'm using 
the head command to take the output from gomock and display only the first 
few lines.)

-- 
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: IDE for GOLANG

2016-08-06 Thread Simon Ritchie
Having read the question yet again, I think my answer is as wrong as the 
others.  Sorry about that.

He's already decided to use the Revel framework to build his web service.  
What he appears to want is a piece of software that will create the web 
service for him.

Is that correct, Kritika?



On Saturday, August 6, 2016 at 9:51:56 AM UTC+1, Simon Ritchie wrote:
>
>
> Actually, I think the word IDE in the question is a red herring.  Kritka 
> is asking how to create web services that follow the MVC model.  All of the 
> answers are about somebody's favourite IDE.
>
> Kritika:  if you search Google for "golang web service mvc framework" you 
> will find information about MVC frameworks.  As usual, you can find any 
> information you want on Google, but only if you know the right words - you 
> want a framework, not an IDE.
>
> For what it's worth (which is not much) I've heard good things about 
> Gorilla.
>
> Once you have chosen your framework, you might want to use an IDE to 
> organise and edit your source code.  You don't have to, you can use just a 
> text editor and a terminal to type commands.  Like one of the other people 
> who have posted comments, I'm currently using liteide, but I would disagree 
> with the comment that it's the best.  More like adequate and the least 
> worst that I've found so far.
>
>
> On Tuesday, August 2, 2016 at 1:25:21 PM UTC+1, kritika...@indiamart.com 
> wrote:
>>
>> Hi, 
>> is there IDE for creating a web service in GOLANG by using Revel 
>> framework  which follows MVC architecture.
>>
>> i am using Ubuntu ..
>>
>>
>>
>> *Watch our latest TV Commercial #IndiaKiKhoj 
>> <https://youtu.be/SoBcg2z0pZE%20%20>*
>>
>

-- 
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: IDE for GOLANG

2016-08-06 Thread Simon Ritchie

Actually, I think the word IDE in the question is a red herring.  Kritka is 
asking how to create web services that follow the MVC model.  All of the 
answers are about somebody's favourite IDE.

Kritika:  if you search Google for "golang web service mvc framework" you 
will find information about MVC frameworks.  As usual, you can find any 
information you want on Google, but only if you know the right words - you 
want a framework, not an IDE.

For what it's worth (which is not much) I've heard good things about 
Gorilla.

Once you have chosen your framework, you might want to use an IDE to 
organise and edit your source code.  You don't have to, you can use just a 
text editor and a terminal to type commands.  Like one of the other people 
who have posted comments, I'm currently using liteide, but I would disagree 
with the comment that it's the best.  More like adequate and the least 
worst that I've found so far.


On Tuesday, August 2, 2016 at 1:25:21 PM UTC+1, kritika...@indiamart.com 
wrote:
>
> Hi, 
> is there IDE for creating a web service in GOLANG by using Revel framework 
>  which follows MVC architecture.
>
> i am using Ubuntu ..
>
>
>
> *Watch our latest TV Commercial #IndiaKiKhoj 
> *
>

-- 
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: Go is for everyone

2016-07-20 Thread Simon Ritchie
I taught C to second year undergraduates back in the 1990s.  By this time, 
they had done some COBOL (those were the days), Pascal and assembler.  Two 
things they had great difficulty with were pointers and multithreading.  
Multithreading is not such an issue because you can avoid it while they are 
learning the basics, but you couldn't avoid pointers for long.  Go is, if 
anything, even worse, because pretty much as soon as you introduce 
functions you have to get involved in pointers, because without pointers 
you can't write a function that sets data.  Other languages such as Java 
manage to hide pointers sufficiently well that you don't have to get to 
grips with them until you have the rest of the language under your belt.  
Actually, I'm guessing that there are lots of successful Java programmers 
out there who have never really understood those things that Java calls 
references.

To be honest, I'm not entirely sure why pointers are such a big issue for 
students who had done a bit of assembler, but trust me, for some they are.  
I think one reason may be that they are one of a set of related concepts, 
and you have to understand them all before any one of them makes sense.

Multithreading is a different matter. I just found that many people have 
great difficulty visualising several threads working at the same time.

Apart from those specific issues, people new to programming have great 
difficulty with the idea of (a) variables and (b) expressions.  These very 
fundamental and crucial ideas are actually quite hard to grasp.  To a 
newcomer, it all just looks very arbitrary.  I have a variable called 
"total", but it could just as  easily be called "wibble".  Why is it called 
"total" then?  What are the rules?  This variable contains a string.  
What's a string?  Oh, it's a bit of text.  Why would I want to store a bit 
of text?  Because the instructor understands these concepts very well, they 
often don't appreciate how difficult some people find them at first, and 
they take them at too fast a pace.

Changing tack completely, I've also encountered a different problem.  Most 
people are only interested in computers when they do useful things - useful 
to them.  So, the instructor shows them a program that takes two numbers, 
adds them together and displays the result.  They can do that themselves 
with a calculator.  Take a list ten numbers that are out of order and sort 
them.  Why not just write the list in the correct order in the first 
place?  What's the point of all this?  Many people are just not willing to 
go through many hours of artificial examples on the assumption that they 
might one day learn something useful.  You have to convince them before you 
begin that they are going to learn something useful (to them) and keep them 
on board throughout.

If you think about it, *why not just write the list in the correct order in 
the first place?* is actually a fundamentally important question, involving 
stuff that we are good at, and computers are bad at.  We can just look at a 
small list of numbers and write it down in sorted order.  Why can't the 
computer do that?   The answer to you is probably so obvious that it 
shouldn't need explaining, something on the lines of "it's not the same 
problem when you have a million numbers", but then why would I be 
interested in sorting a million numbers into order?

Sorry if this is a bit vague.  I've been thinking about this stuff ever 
since I gave up teaching many years ago.  I know what some of the problems 
are, but I'm really not certain of the answers.

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


[go-nuts] Re: How to manage a web portal with multiple services without stopping and restarting everything at each release/fix?

2016-06-19 Thread Simon Ritchie
I think you will be hard put to match the performance of a PHP application on 
restart, and it may be faster in general.  I've always assumed that this is due 
in part to the fact that the app is embedded in the web server and in part to 
the essential simplicity of the framework - PHP doesn't do as much for you as 
an industrial-strength application server, but what it does do, it does very 
efficiently.  However, now that hardware is cheap and software development 
remains expensive, we can throw hardware at the performance issue and use 
frameworks that support rapid and relatively cheap development.  It's just a 
cost benefit equation - over some sensible lifetime, say five years, your app 
will cost X to develop and maintain, the equipment to run it will cost Y and 
then Z per year to supply electricity and air conditioning - you pay to heat up 
the computers, then you pay again to cool them down.  If your PHP app can run 
on less powerful equipment, the running costs will be lower.  However, in an 
app of any complexity, X will be the biggest cost, so that's the one to 
concentrate on.  Testing will be the lion's share of that cost, so you want a 
framework that supports effective testing.

The problem with PHP is the other side of the same coin - simplicity.  Other 
frameworks do more for you, and It's much cheaper to write a reliable, robust 
and scalable application using something like Go or Java.  Java is a very 
mature product, and so it's easy to find developers who know it.  Go is quite 
immature in comparison but it has all sorts of advantages such as native code 
generation and rapid garbage collection.

My guess is that you are looking at Go because you've reached the point where 
your PHP app is costing too much to maintain.  If I'm wrong that you are in 
this situation, I think a lot of other people are.  Five years ago I would have 
advised you to look at Java, but now we have Go as well.  Whichever you choose, 
it will not be as good as PHP in some respects and I predict that speed of 
redeployment will be one of them.

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


[go-nuts] Re: How to manage a web portal with multiple services without stopping and restarting everything at each release/fix?

2016-06-17 Thread Simon Ritchie
This is not a question about Go, but basic web infrastructure.  However, 
it's one of those "best practice" questions which "everybody knows the 
answer to" and so you may be hard put to find out more without knowing 
where to start.

First of all, I should point out that when you tweak your PHP page, that 
does cause a service outage, but it's very short, and you usually don't 
notice. 

The usual solution to this problem is to use a team of web servers behind a 
load balancer or a reverse proxy.  A load balancer is a commercial product 
and most router manufacturers supply them, Cisco to name but one.  You can 
build your own reverse proxy using the Apache web server.  The Apache 
documentation explains how.

A reverse proxy is a web server that stands between the client web browsers 
and a team of web servers that do the work.  The proxy takes each incoming 
request and sends it to one of the web servers, then relays the response 
back to the client.  it looks to the client that the proxy is its web 
server, but actually it's just relaying requests and responses.  Add the 
ability to put extra worker servers into the team and take them out and you 
have your solution.  When you want to restart a server, you remove it from 
the team, restart it and then put it back, so at no time are all the 
servers out of action.  You need to arrange that there are always enough 
servers to cope with the traffic.

If you visit a large website such Google or Amazon, you are almost 
certainly talking to some sort of reverse proxy with lots of workers behind 
it.

The worker servers are usually called "application servers" , so you have 
the classic chain of: load balancer, web server, application server.  In 
your case, your Go software will run on the app servers.

Access to the app servers should be disallowed by the network except by the 
web server.

One of the advantages of the REST approach to web design is that your 
servers can be stateless, so each request can be sent to any old server.  
(With a statefull protocol, the proxy may need to keep track of sessions of 
associated requests and send all of the request in the session to the same 
worker.)

It's also common to terminate any SSL connections at the web server, ie the 
clients communicate with the web server via HTTPS, but it communicates with 
the app servers via HTTP.  Being encrypted, HTTPS requires significant 
extra work and Apache, in particular, is very good at this. 

A load balancer is a reverse proxy with lots of extra features.  In 
particular it may have more than one connection to the internet, so if 
there is a problem with one of the connections, it will still work.  Load 
balancers themselves can be more than one machine working as a team, 
possibly on different sites.  By spending (a lot) more money you can 
increase the reliability of your web service by having equipment in 
separate buildings on separate sites with a distributed load balancer 
network, Internet connections from different providers coming into 
different parts of the buildings and arriving at your equipment via 
different physical routes, multiple redundant uninterruptable power 
supplies, backup diesel generators, and so on. 

One organisation I worked for ran two buildings, one on each side of 
London, both staffed and each with enough equipment to provide the web 
service single-handed.  The thinking was that there was small chance of one 
building being destroyed by war, flood, fire or a plane crash.  They 
switched the production service between the buildings regularly to make 
sure that everything still worked.  This is not a cheap solution, but they 
were in the banking sector and they could afford it.

On the more affordable side, cloud services often provide a load balancer 
as part of the mix.

This is general web infrastructure wisdom and nothing to do with Go, so 
let's not let this discussion run on.  There should be enough above to help 
you choose the right Google searches.  Unless anybody thinks that what I've 
written contains any major blunders, let's all get back to talking about Go.

(If anybody wants to contact me directly for help with this sort of stuff, 
I'm a contractor and my daily rate is only slightly heinous.)

Hoping that this helps.

Simon


On Thursday, June 16, 2016 at 4:02:50 PM UTC+1, romano.p...@gmail.com wrote:
>
> Hi All,
>
> Forgive me if I posted in the wrong group, as it could be more of a 
> question related to design patterns rather than to golang itself.
>
> *The context*
> Imagine to create a full portal with users, profiles, ... and multiple 
> services that can be activated for different customers.
> I can organise the code of my portal in modules so to have a "quite" clear 
> use of golang packages, but at the end of the day I get to a unique EXE 
> file that represents my server/portal.
>
> When I start it, the portal runs. Perfect.
>
> To make an example, think of google, where you have Drive (Service 1) and 
> Gmail