环境
- 龙芯测试环境:基于泰晓科技/Linux Lab 搭建
- 主机macOS
- golang:1.15
macOS
Product: Apple, MacBook Pro, MacBookPro11,3
ARCH: x86_64
CPU: 4 x Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
RAM: 16 GB
System: Mac OS X, 10.15.5, 19F101
Kernel: Darwin 19.5.0
Docker: Docker version 19.03.12, build 48a66213fe
Shell: /bin/bash 3.2.57(1)-release
$ go version
>> go version go1.15 darwin/amd64hello world
package main
import (
"fmt"
)
func main() {
fmt.Println("你好,go!")
}
以下两种方式的编译都可以测试通过,
$ GOOS=linux GOARCH=mips64le go build -o hello.mips64le main.go
$ GOOS=linux GOARCH=mipsle go build -o hello.mipsle main.go因为虚拟机里软件很少,于是在服务器上用php建了个临时的http server
$ php -S 0.0.0.0:9999 -t .虚拟机里通过wget下载
$ wget http://192.168.16.194:9999/hello.mipsle
$ chmod +x hello.mipsle
$ ./hello.mipsle
>>你好,go!hello world 并不能说明什么,下面试试一个真正的项目,
csvq
csvq可以使用SQL来访问csv,具体功能如下,
- CSV File Operation
- Select Query
- Insert Query
- Update Query
- Replace Query
- Delete Query
- Create Table Query
- Alter Table Query
- Cursor
- Temporary Table
- Transaction Management
- Support loading data from Standard Input
- Support following file formats
- CSV
- TSV
- LTSV
- Fixed-Length Format
- JSON
- Support following file encodings
- UTF-8
- UTF-16
- Shift_JIS
JSON Format supports only UTF-8.
编译
$ go mod init github.com/alitrack/loongson
$ GOOS=linux GOARCH=mips64le go build github.com/mithrandie/csvq
$ file csvq
>>
csvq: ELF 64-bit LSB executable, MIPS, MIPS-III version 1 (SYSV),
statically linked, Go BuildID=sJeKyEzNMH7R3f7vESdD/xcu7ueu7zo2SjgZW_4XA/oJRl68hxh47yttNwEaaJ/FQGcytucuQ0UWsabOtPz, not stripped上传到虚拟机测试下
$ wget http://192.168.16.194:9999/iris.csv
$ wget http://192.168.16.194:9999/csvq
$ ./csvq "select count(*) from iris"
>>
+----------+
| COUNT(*) |
+----------+
| 150 |
+----------+
$ ./csvq "select * from iris limit"
>>
+--------------+-------------+--------------+-------------+---------+
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
+--------------+-------------+--------------+-------------+---------+
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
| 4.9 | 3 | 1.4 | 0.2 | setosa |
| 4.7 | 3.2 | 1.3 | 0.2 | setosa |
| 4.6 | 3.1 | 1.5 | 0.2 | setosa |
| 5 | 3.6 | 1.4 | 0.2 | setosa |
| 5.4 | 3.9 | 1.7 | 0.4 | setosa |
| 4.6 | 3.4 | 1.4 | 0.3 | setosa |
| 5 | 3.4 | 1.5 | 0.2 | setosa |
| 4.4 | 2.9 | 1.4 | 0.2 | setosa |
| 4.9 | 3.1 | 1.5 | 0.1 | setosa |
+--------------+-------------+--------------+-------------+---------+
$ uname -a
>>
Linux linux-lab 3.10.0 #57 SMP PREEMPT Tue Jul 23 04:49:46 UTC 2019 mips64 GNU/Linux
$ cat /proc/cpuinfo
>>
system type : generic-loongson-machine
machine : loongson,generic
processor : 0
cpu model : ICT Loongson-3 V0.5 FPU V0.0
model name : ICT Loongson-3A R1 (Loongson-3A1000) @ 200MHz
BogoMIPS : 83.23
wait instruction : no
microsecond timers : yes
tlb_entries : 64
extra interrupt vector : no
hardware watchpoint : yes, count: 0, address/irw mask: []
isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips64r1
ASEs implemented :
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not availablelinux-lab还不错,除了有时候莫名其妙的死机的感觉,只要重新开个workspace就好了。