Skip to main content

Posts

Showing posts with the label Go

Ahmedabad Shopping festival

Ahmedabad Shopping festival is solution created by  Tuzzin Infotech Pvt. Ltd . I worked as part of the development team My journey started as a part-time web developer. A MySQL database, Php for backend, VueJs and jQuery frontend, scss for css and I'm done. So easy! I was never thinking about scaling, rate limiting, timeout on those days, and normal site even does not need to care about such things unless they reaches that threshold. Luckily, I got chance to work on a product which was requiring all of this. It was the first time when I got exposure to real scalable application with spike in traffic, Ahmedabad Shopping festival 2019.   Brief Intro of Ahmedabad Shopping festival  Ahmedabad Shopping festival was first digitally managed shopping festival of India hosted in Ahmedabad, Gujarat. Every customer were getting rewards and coupons for chance to win prize on making shopping during shopping hours . Technical requirements Ahmedabad Shopping festival was con...

Creating 2d games with golang and gontuz/prototype

Golang was created as server language. But with the time and curiosity of people, golang has covered GUI application and game development as well. I am sharing here one of the available golang library, on top of which you can create 2d games. Its gonutz/prototype . Sample video Gonutz/prototype is very small and easy to learn library. It's cross-platform , that means the game your are creating in one platform will be able to run on other platforms without any change in code ( in normal case ).  This package currently supports windows , mac and linux. gonutz/prototype features Support for keyboard input Support for mouse input Support for 2d drawing Support for image and sprite-sheets Support for sound  Want to learn more about this package.  Follow my youtube video playlist "2d game development in golang" Video tutorial playlist:   https://www.youtube.com/playlist?list=PLub5C2vM5SjJIF0f561mAON7nFG2nKHD9

Go-boiler : smaller and simplest starter kit

Project Name  Go-boiler Project Descrtiption Simple, small & easy to get started boiler-plate(starter-kit) written in golang for creating website/webapps. External libraries Cloudykit/Jet ( HTML templating engine) gorilla/mux ( HTTP Routing ) gorilla/csrf ( CSRF ) Source code https://github.com/mchampaneri/go-boiler Documentation https://mchampaneri.github.io/go-boiler

Find count of day differance between two dates

In golang there is no direct way [ atleast i don't know ] to find count of differance in days between two days. So, I do it the way might every one does [ except who has already faced this ]. Partial Solution What I does is just find out duration differance of two dates using sub function. differance := time.Now().Sub( startTime ) daysCount := int(differance.Hours() / 24.0) It might seem ok. But, there is a problem with this solution.  Let assume, startTime is 2018-02-02 23:59:59 .   In this case daysCount will be 0 on next day [ 2018-02-03 ] until time is 2018-02-03 23:59:59. Perfect Solution Simple solution is just normalize startTime to starting of that date . normalizedTime := time.Date(startTime .Year(),startTime .Month(),startTime .Day(), 0, 0, 0, 0, time.Local) differance := time.Now().Sub( normalizedTime ) daysCount := int(differance.Hours() / 24.0) normalizedTime is startTime but at starting of date. So, Now we are subs...

Use packfolder to archive your resource

In commit 25d8ed42e0bb4c4acb742de9f148f6902d32ff41 go-sciter SDK has added one new facility which automatically resolves file path for archived data . Now you can use archived data from the archive and it will resolve import by itself, as it does for c & c++. Packfolder packfolder is utility provided as part sciter-sdk. It compresses resources folder under a single file of the format of your choice ( should support by packfolder ). Currently, supported output format files are bin ( normal binary file ) an array of bytes in c, go, d and rust language.  Syntex is , [path]\packfolder.exe [resource-folder] [resource-file].[ext] -V [name-of-variable] -[output-format] path = full / relative path to packfolder.exe to execute command resource-folder = full/relative path to the folder inside which your resouce is contained resource-file  = name of the file you want as your output file  name-of-variable = it will the name of the varilble that will iniated with the a...

Remove console screen for your gui application written in go

Remove console screen for your gui application written in go Images of appliaction used as example is notepad plus minus. I writen as example. To get details of this program you can visit post " Simple document based application with golang " You write a GUI application and it runs with a console screen behind. It looks pretty weird, right! I mean what is the meaning of a console when console actually not going to interact with the user.  GoLang Gui Application with Console Screen Don't know how this works on Mac or Linux as I have not done this on either Mac or Linux. But for windows, I find a way to compile console-less GUI application for golang.  Just build the application with this argument. go build -ldflags "-H=windowsgui" ldflags used to set build time variable. Now. in the upper statement we are saying golang that current application we are building is windowsgui application so don't create the console with it. J...

Simple Calc using golang and sciter-sdk

calc usin golang andsciter Last Update : 18-07-2018 Up to this, we know how to create a window, put elements inside it, get input from the user and convert them in datatype we want. We also know how to pass that converted input data to golang function and update GUI elements according to the response/ result we get from the execution of GUI element. Here I am sharing the code of calc which actually requires all of the elements we have seen in previous examples. GUI File Here  I am sharing GUI file given by Andrew as suggestions. But you can check original GUI code that I have written in case you want to curious how much this code is more optimized than the original code. main-update.html <html>     <head>                <style>                    html { background:transparent; }           div#buttons {           ...

Embed GUI Inside Your Go Code

Embed Gui (HTML) Inside Go code  In every application, you are going to need HTML for your GUI. Now it's not a good idea to put your HTML file with your executable.  Using an HTML file for GUI has two major disadvantages:  Your guy is loading from HTML file so you have to be sure about the location of your HTML file. Your HTML code is now reachable to end user with which they can play. So Safer option is to embed your HTML inside your go program. You can do this with two ways, first is go with go-rice like tools which actually makes single executable consisting of your every resource file ( which consist your HTML, CSS and even images!, but I have not used it so have no more idea about it ) The second way to embed HTML is to write your HTML inside your code as a string.  To make it more clearly see the example below. Golang File main.go package main import ( "fmt" "github.com/sciter-sdk/go-sciter" "github.com/sciter-sdk/go-sciter/window" ) f...

Process Input Grabed From TIScript in Golang

process golang input in sciter In the real-world scenario, you have to get input from the user via GUI and then have to pass it down to go code for the further process. For example, let's say you are just creating a simple to-do app which takes the input of task and then stores it in the SQLite table which is handled by go code. In that case, you have to take data from the user using HTML and sciter and then have to pass that data to go code. Though the upper scenario is more real, we will go with a very simple example [ as still, we are in earlier stages ]. We will take two integer inputs from the user and then send those inputs to go function that will show the response given by code in the GUI over a label. First Lets See a working demo  Main goal of this post is to show you use of  ' view  ' in TIScript and ' DefineFunction ' function in GoLang File. So let's see the GUI File First.  GUI File First of all we will setup our input elements to get integers (...