mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-11 12:11:39 +00:00
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.
-
If you have already installed Go, you will need to remove it first.
$ brew remove go -
First of all, you will need to build the compilers, using:
$ brew update
$ brew install go --cross-compile-common -
Check that your Go installation enviroment is ok running:
$ go env -
Install Gin framework:
$ go get github.com/gin-gonic/gin -
Create a simple web server using Gin, listening on port 8080:
$ nano main.gopackage 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") } -
Compile your program using:
$ GOARCH=arm GOOS=linux go build main.go -
Copy the binary file to an executable place in your ROOTED Android, give it permissions and run it:
$ su
# ./main