1 Run Gin web framework on Android
Javier Provecho edited this page 2014-07-06 09:28:18 -07:00

In this post we will explain how to compile a Gin web server for Android using a Mac.

  1. If you have already installed Go, you will need to remove it first.
    $ brew remove go

  2. First of all, you will need to build the compilers, using:
    $ brew update
    $ brew install go --cross-compile-common

  3. Check that your Go installation enviroment is ok running:
    $ go env

  4. Install Gin framework:
    $ go get github.com/gin-gonic/gin

  5. Create a simple web server using Gin, listening on port 8080:
    $ nano main.go

    package main
    
    import "github.com/gin-gonic/gin"
    
    func main() {
        r := gin.Default()
        r.GET("/ping", func(c *gin.Context){
            c.String(200, "pong")
        })
    
        // Listen and server on 0.0.0.0:8080
        r.Run(":8080")
    }
    
  6. Compile your program using:
    $ GOARCH=arm GOOS=linux go build main.go

  7. Copy the binary file to an executable place in your ROOTED Android, give it permissions and run it:
    $ su
    # ./main

GoLang Gin Web Framework Running On Android