The Go Language (Golang) simplifies cross-platform cross-compilation steps, enabling cross-compiling of Arm+linux platform-based applications under Windows systems without the need for additional dependent libraries at runtime. The following is a simple HTTP server for example, the first source:
************************************************************
Package Main
Import (
"Net/http"
)
funcMain () {
http. Handle ("/", HTTP. Fileserver (http. Dir ("HTML")))
http. Listenandserve ("0.0.0.0:8080", nil)
}
************************************************************
The code in the main function shows:
First line: Set the home directory as the HTML directory in the startup directory
Second line: Start the HTTP service, listen on port 8080
************************************************************
Step 1: Install the Go Language development environment and Visual compiler Liteide under the Windows system (I'm using WIN10) (the steps are simple, many online tutorials)
Step 2: Create a new Go1 Command Project, named "Test"
Step 3:import is modified to "Net/http", the main () function is modified to the following two lines of code:
http. Handle ("/", HTTP. Fileserver (http. Dir ("HTML")))
http. Listenandserve ("0.0.0.0:8080", nil)
Step 4: The target environment is modified to CROSS-ARM6, according to "Ctrl+b" compiled, the generated execution file is the source directory "Test", no suffix
Step 5: Copy "Test" to your arm Development Board (Raspberry Pi Raspberrypi, Orange pie Orangepi), and authorize: sudo chmod 777 test, while creating a new "HTML" directory in the "test" directory, run./test
Next, you can access the HTTP service via/HTTP Development Board ip:8080, remember to create a new "HTML" directory, put in some HTML files/other files, you can browse and download like a regular website.
************************************************************
1. This example creates a static Web site that adds HTTP to the main function. Handlefunc can increase dynamic processing power
2. In Raspberry Pi 2b,orange Pi Lite test pass (ARM version forward compatible)
Golang 2 lines of code running an HTTP Web service on an arm Linux-based Raspberry Pi, Orangepi