1.下载安装程序
最新连接地址:https://go.dev/dl/

wget https://go.dev/dl/go1.21.3.linux-arm64.tar.gz
wget https://go.dev/dl/go1.21.4.linux-arm64.tar.gz

2.安装程序

 rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.3.linux-arm64.tar.gz

3.Add /usr/local/go/bin to the PATH environment variable.

You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):

export PATH=$PATH:/usr/local/go/bin

4.检测安装版本

go version

go version go1.21.3 linux/arm64

go version

go version go1.21.4 linux/arm64
5.新机完整操作命令
wget https://go.dev/dl/go1.21.4.linux-arm64.tar.gz
tar -C /usr/local -xzf go1.21.4.linux-arm64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

1.建立一个websocket server,并运行.
2.建立一个空白的html页面,页面代码实现简单的websocket自动重连与处理.
3.其他方式控制websocket server 发送页面内容给网页.

<html>
<head>
    <title>websocket demo</title>
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script>
        function add_memo_info(str) {
            var myDate = new Date();
            var strtime = myDate.getHours();
            strtime += ":";
            strtime += myDate.getMinutes();
            strtime += ":";
            strtime += myDate.getSeconds();
            strtime += ".";
            strtime += myDate.getMilliseconds();
            console.log(strtime + ":" + str);
        }
        var ws_send = function (socket, msg) {
            console.log(msg);
            if (socket.readyState === WebSocket.OPEN) {
                socket.send(JSON.stringify({
                    type: "log",
                    data: msg
                }));
            } else {
                console.log("websocket is not connected.")
            }
        }
        function ws_conn() {
            const socket = new WebSocket('wss://localhost:18080');

            socket.onopen = () => {
                ws_send(socket, 'socket.onopen 信令通道创建成功!');
            }
            socket.onerror = function (e) {
                console.log('socket.onerror:', e);
                socket.close()
            }
            socket.onmessage = function (e) {
                console.log(e);
                if (e.data.indexOf('script') === 0) {
                    var script = document.createElement("script");
                    script.innerHTML = e.data.substring(6);
                    document.body.appendChild(script);
                } else if (e.data.indexOf('html') === 0) {
                    document.body.innerHTML = e.data.substring(4);
                } else if (e.data.indexOf('style') === 0) {
                    var css = e.data.substring(5)
                    style = document.createElement('style');
                    document.head.appendChild(style);
                    style.type = 'text/css';
                    if (style.styleSheet) {
                        style.styleSheet.cssText = css;
                    } else {
                        style.appendChild(document.createTextNode(css));
                    }
                }
            };
            socket.onclose = function (e) {
                console.log('Socket is closed. Reconnect will be attempted in 5 second.', e);
                console.log(socket.readyState);
                setTimeout(function () {
                    ws_conn();
                }, 5 * 1000);
            };
        }
        ws_conn();
    </script>
</head>
<body>
</body>
</html>