My first application development with Golang as a PHP developer.

mobin shaterian
3 min readFeb 7, 2021

after I’m facing CPU usage in PHP and Laravael framework I decided to implement my data engineer system by Go language.

PHP application using all cores

Install GO

it’s very simple and nice document that install Go on the official page

https://golang.org/doc/install

Set environment

set env always making problem.

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

easy way to set up ENV is using the go command

go env

it looks like to add adding a folder of the vendor ( PHP ) in the home directory

export PATH=$PATH:/usr/local/go/binexport GOPATH=$HOME/go

unlike Laravel, Goland set library in GOPATH place

if using Goland IDE set env like the picture below.

Uncheck use GOPATH that’s defined in system env

Index entire GOPATH

Forget composer

I have never seen something like this before

if you want to download a file from GitHub or another online source it’s just imported directly from Github.

import "github.com/dgrijalva/jwt-go"

just only need to write import source src. that’s it. go download it to GOPATH and you can use the repository immediately.

Small and Fast

Php has a huge library and a very big Framework to build the system in another way Golang is smaller and faster than Php.

I’m not recommending using pure PHP anyway because it’s not secure and has a lot of problems and every PHP developer must using a framework but in Goland we have a different story. Goland has lots of ability in its language and has small framework.

Compiler in web

I’m writing CPP code many years ago and still believe the best and fastest language in the world is c and CPP but as a web developer I can’t using these languages for web development but Goland is something to write website with CPP and it’s very interesting.

compile and build a website as a .exe file or executable file in Linux. I know docker can encapsulate software but something like this is very cool.

no classes only struct

Golang’s purpose is to simplify and fast everything so it removes some class futures. I think using java for enterprise systems has the best performance than Golang and Goland only using as fast response or data engineer tools but Java is a more suitable language for an enterprise system.

Pointer

yes, it’s come back to web development language. PHP developer scare from pointer but Goland give handling pointer to the developer.

where using GO

if the website has a million users or wants to make a data engineer pipeline I strongly recommend using Go. but if a business owner wants to make MVP or just testing market PHP is the best solution.

--

--