Skip to content

Rust、Go

更新时间:2023-12-31

Rust安装

sh
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustc --version
rustup update
  • 新建项目和添加依赖
sh
cargo new dir --name demo		#--lib or --bin
cargo add slint					#--target
cargo add slint-build --build
cargo add rusqlite --features "bundled"
cargo update -p clap --precise 3.2.23
cargo remove slint				#del pkg

Rust编译

sh
cargo build
cargo check

Tauri

  • 编译Tauri遇到的错误解决
sh
find / -path /mnt -prune -o -name pkgconfig
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:$PKG_CONFIG_PATH
apt-get install javascriptcoregtk-4.1 libsoup-3.0 webkit2gtk-4.1 -y

交叉编译

sh
cargo install cross			#need install gcc docker
cross build --target aarch64-linux-android --release

Go环境

sh
wget https://dl.google.com/go/go1.23.7.linux-amd64.tar.gz	#Download
tar -zxvf go1.23.7.linux-amd64.tar.gz						#Extract
export PATH=$PATH:/root/go/bin && go version				#Env
sh
go mod init main
go get github.com/webview/webview_go
go mod tidy
go env -w GO111MODULE=on GOPROXY=https://mirrors.aliyun.com/goproxy/,direct GONOSUMDB=*		# GO ???`

Copyright © manosP . 2023