Shell脚本实现#!/bin/bash echo "开始发布" cd /run-path echo "同步代码" git pull echo "编译项目" go build -o /build-file-path -ldflags "-w -s" ./ echo "停止当前服务" pid=$(ps -ef | grep 'keyword' | grep -v grep | awk '{print $2}') if [ -n "$pid" ]; then kill -9 $pid else echo "服务未启动" fi echo "重启新服务" cd /run-path/ sleep 1 echo "重启新服务" if [[ -f "${release_dir}build_last" ]]; then echo "存在新版本文件,尝试替换
解析方法package main import ( "encoding/xml" "errors" "fmt" "os" ) type TConfig struct { ListenServer string `xml:"listen"` PhoneDict string `xml:"dict"` } var GConfig *TConfig func ParseXmlConfig(path string) (*TConfig, error) { if len(path) == 0 { return nil, errors.New("not found configure xml file") } n, err := GetFileSize(path) if err != nil || n == 0 { return ni
govlc编译到windows并隐藏cmdGOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui" -o test.exe wails编译到windowswails build -platform windows/amd64 -o test.exe
实现代码界面定义type AppGUI struct { baseDir string // 文件目录 songs []string // 歌曲集合 curSong *MusicEntry // 当前歌曲 currentSongName *widget.Label // 当前曲目名称 progress *widget.ProgressBar // 播放进度 consumedTime *widget.Label // 已用时间 remainedTime *widget.Label // 剩余时间 playBtn *widget.Button // 播放 paused bool // 是否暂停标志 nextBtn
依赖库# 安装工具pkg sudo apt install pkg-config # 安装 alsa 开发库 sudo apt-get install libalsa-ocaml-dev 主要代码package main import ( "log" "os" "time" "github.com/faiface/beep" "github.com/faiface/beep/mp3" "github.com/faiface/beep/speaker" ) func main() { f, err := os.Open("./Lame_Drivers_-_01_-_Frozen_Egg.mp3") if err != nil { log.Fatal(err) } streamer, format, err := mp3.Decode(f)