[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 applic

[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 writ

[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 cg

[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

[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 w

[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

[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 M

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, Septemb

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 shou

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

[go-nuts] Re: go get awkwardness with packages outside of GOPATH

2017-07-21 Thread Simon Ritchie
Just a simple clarification. Your GOPATH variable can contain many directories, as already pointed out. If so, go get will download packages into the FIRST directory in the path. One use of this is to have your own go projects in separate directories with a single shared set of packages loade

[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 eve

[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 m

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 informati

[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 la

Re: [go-nuts] Re: [ANN] scaffolder - web application servers to order

2017-05-15 Thread Simon Ritchie
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,

[go-nuts] Java to Golang converter

2017-05-11 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 le

Re: [go-nuts] Re: [ANN] scaffolder - web application servers to order

2017-05-11 Thread Simon Ritchie
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, Simo

[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 Ru

[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/gob

[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 ot

[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

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 in

[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 b

[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 lot

[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 sub

[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 addre

[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

[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

[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 S

[go-nuts] Re: best working and maintaned golang oauth2 server package

2017-01-11 Thread Simon Ritchie
I've just started work on an OAUTH server too. So far I've built the "simple" example of the RangelReale project. It takes a user name and password and produces a token, so it seems to do pretty much all the things that you need. It also gives a reference to the OAUTH RFC. If you haven't do

[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 o

Re: [go-nuts] Re: XML Beautifier that doesn't rewrite the document

2016-11-06 Thread Simon Ritchie
I have a much simpler approach which works for me. Open the document with a web browser and it displays it nicely formatted. If you want to put the result back into the document, open it with a text editor and cut and paste. I found that Chrome is much faster than Firefox for some large XML fi

[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 eng

Re: [go-nuts] Re: Which web framework is recommended to use with GO?

2016-09-29 Thread Simon Ritchie
> I am looking at building a rest API system ... Looking to use MVC pattern. I have implemented a very simple database-driven website built using MVC. It has a single table and RESTful requests implementing the CRUD operations on the table. The design supports the use of interfaces and Inversi

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

[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 paren

[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 betw

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

2016-09-07 Thread Simon Ritchie
When I said that you can only mock well-behaved classes, I should have said more. When I say mock, I mean something that satisfies an interface and drives a test. You can also use what I call a dummy to drive your test. To me a dummy is a real structure, such as an http Request, which you cre

[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 nee

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

[go-nuts] Re: totalling a column in a html template.

2016-08-25 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

Re: [go-nuts] Simple test runner

2016-08-12 Thread Simon Ritchie
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 pr

[go-nuts] Simple test runner

2016-08-11 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

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

2016-08-07 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 la

[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 pa

[go-nuts] Re: IDE for GOLANG

2016-08-06 Thread Simon Ritchie
itika? 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

[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

[go-nuts] Re: importing the structure and methods from other folders

2016-08-03 Thread Simon Ritchie
This looks like a simple question, but actually it takes a bit of thought and experimentation to arrive at a working structure. I'm also working on an MVC solution. I've set up the source code structure so that it's ready to commit to github, but the first version is not complete, so it's not

[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 a

Re: [go-nuts] Return different structs

2016-06-30 Thread Simon Ritchie
By the way, this is covered by in Donovan & Kernighan's new book The Go Programming Language. On pages 197 and 198 of the first edition, they describe an interface Expr, representing an expression, then five concrete types that satisfy that interface and contain different sorts of expressions a

[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 a

[go-nuts] Re: When should I use the connection pool?

2016-06-18 Thread Simon Ritchie
Every database offers a limited number of connections because each of them eats resources. If you are using your database in a commercial environment, you configure your database with a maximum number of connections. If you don't do that, the DB will configure some default maximum, it won't o

[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 pa