Go Language – First Impressions

Just wrote something small with Go Language. Simple CRUD/webservice with MySQL using gorilla mux and sqlx, but it is almost plain golang. If anything wrong about it, tell me 😉

Here are my impressions about it:

  • it feels pragmatic from the beginning
  • probably you don’t need any frameworks at all to use it
  • simpler = better, simplicity as a feature
  • quite easy to write REST application
  • the build in package manager ‘go get’ is cool thing
  • compilation & running time of go server is much faster than java
  • it doesn’t eat much of resources
  • you can use many text editors or IDEs for it (IntelliJ has Go Plugin)
  • gofmt – one and the only code formatter
  • designed for special needs, not for everything
  • it is easy to find examples by googling it, good enough community
  • return multiple values from Go functions – nice feature
  • syntax not beautiful like Python but still good
  • the build in ‘testing’ package – ok, but too simple (testify looks better)
  • concurrency – believe that it is nice, but didn’t tried it yet
  • it is much different than Scala – complexity vs simplicity
  • I think that I could be very productive with Go if i will get used to it
  • Docker, Kubernetes, CoreOs,  Consul, Flynn, Lime, Google, Dropbox…
  • heard that golang is good for ‘real time apps’ – want to try it soon
  • it seems to be good for building command-line tools
  • it is different than Java, little bit tricky at beginning, but easy to start 😉
  • ‘good when you need to write something yourself instead of using library’
  • need to find idea for real project, because I kinda like Go


Univocity Parsers Library

Very good parsing library.
Official Website
Univocity Parsers – Maven Repository

public class ExampleCsvToPojoParser {
    private final Logger logger = LoggerFactory.getLogger(CsvToPojoParser.class);
    public <T> List<T> parseFileToPojo(Class<T> clazz, String fileName) {
        BeanListProcessor<T> rowProcessor = new BeanListProcessor<T>(clazz);
        CsvParserSettings parserSettings = new CsvParserSettings();
        CsvParser parser = new CsvParser(parserSettings);
        try (InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
        } catch (IOException e) {
            logger.error("Cannot read file " + fileName, e );
        return rowProcessor.getBeans();

Then you can put there class like this (which will match the file):

public class Users {
    @NullString(nulls = { " ", "" })
    @Parsed(field = "USER_ID")
    private Long userId;
    @NullString(nulls = { " ", "" })
    @Parsed(field = "USER_NAME")
    private String userName;
    //getters & setters