Go和Excel

获取包
go get github.com/360EntSecGroup-Skylar/excelize(不需要,程序自动获取v2)
建立test.go

package main

import (
    "fmt"

    "github.com/360EntSecGroup-Skylar/excelize/v2"
)

func main() {
    f := excelize.NewFile()
    // 创建一个工作表
    index := f.NewSheet("Sheet2")
    // 设置单元格的值
    f.SetCellValue("Sheet2", "A2", "Hello world.")
    f.SetCellValue("Sheet1", "B2", 100)
    // 设置工作簿的默认工作表
    f.SetActiveSheet(index)
    // 根据指定路径保存文件
    if err := f.SaveAs("Book1.xlsx"); err != nil {
        fmt.Println(err)
    }
}

go mod init main
go run test.go
生成Book1.xlsx,包含两个Sheet

- 阅读剩余部分 -

关于nginx的proxy_pass

常用配置

location /api {
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://192.168.1.11:8070/;
}

服务在192.168.1.11:8070的/api/路径下
如果配置8070/需要访问/api/api/才能访问到
如果配置中不带/就可以/api/访问到了
替换时location /newapi时需要配置/api,不带结尾的/
总结proxy_pass后尽量不要带/
如果不替换,配置是否带/api似乎差别不大

跨域问题Access-Control-Allow-Origin

Access-Control-Allow-Origin是HTML5中定义的一种解决资源跨域的策略。

他是通过服务器端返回带有Access-Control-Allow-Origin标识的Response header,用来解决资源的跨域权限问题。

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

最好不跨

speedtest网络测速

https://github.com/sivel/speedtest-cli/

python speed.py --csv-header
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
python speed.py --csv
5145,Beijing Unicom,Beijing,2021-01-11T04:49:04.392496Z,1.673922445212346,5.547,628723539.378605,55826659.160589784,,公网IP

python speed.py
Retrieving speedtest.net configuration...
Testing from China Unicom Beijing (公网IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Beijing Unicom (Beijing) [1.67 km]: 6.337 ms
Testing download speed................................................................................
Download: 625.72 Mbit/s
Testing upload speed................................................................................................
Upload: 56.08 Mbit/s

python speed.py --json
{
"client": {"rating": "0", "loggedin": "0", "isprating": "3.7", "ispdlavg": "0", "ip": "公网IP", "isp": "China Unicom Beijing", "lon": "经度", "ispulavg": "0", "country": "CN", "lat": "纬度"},
"bytes_sent": 70762496, "download": 596758926.7716337, "timestamp": "2021-01-11T04:56:33.105784Z", "share": null, "bytes_received": 409373932, "ping": 5.535, "upload": 55883940.61967305,
"server": {"latency": 5.535, "name": "Beijing", "url": "http://bj3.unicomtest.com:8080/speedtest/upload.php", "country": "China", "lon": "经度", "cc": "CN", "host": "bj3.unicomtest.com:8080", "sponsor": "Beijing Broadband Network", "lat": "纬度", "id": "5505", "d": 1.673922445212346}
}

GPS和地图

光速30万公里/秒,地球七圈半,一圈4万公里;一圈360度,3万6公里,一度10万米(100公里)
0.00001度,万分之一度,就是10米,应该也够用了,还是用四舍五入吧
实际好像4位东西向10米,南北向20米,哪里算错了?五位小数应该是十万分之一1米,名址10米,轨迹1米(或者2-2.5米)
https://tool.yovisun.com/longlat/
两点距离:11.11946465529米
点1:纬度:40,经度:116,点2:纬度:40.0001,经度:116
两点距离:8.5184132726564米
点1:纬度:40,经度:116,点2:纬度:40,经度:116.0001

经度0.0001=8.5米,纬度0.0001=11.1米

关于四舍五入
https://www.cnblogs.com/renzhiwei/p/4229384.html