Browse Source

feat: Remove obsolete binaries and update module dependencies

- Deleted outdated binary files for Windows, Linux, and macOS platforms to streamline the project.
- Updated `go.mod` to change the module path to `cursor-id-modifier` and adjusted dependency versions for `github.com/fatih/color` and `golang.org/x/sys`.
- Modified `install.sh` to reflect new binary naming conventions and download URLs.
- Cleaned up whitespace in `main.go` for improved code readability.

This commit focuses on cleaning up the project structure and ensuring dependencies are up-to-date.
pull/20/head
Xx 6 months ago
parent
commit
2e27634c8d
  1. 1
      .vscode/settings.json
  2. BIN
      app.exe
  3. 11
      app.manifest
  4. BIN
      cursor-id-modifier-linux
  5. BIN
      cursor-id-modifier-macos
  6. 12
      go.mod
  7. 15
      go.sum
  8. 9
      install.sh
  9. 113
      main.go

1
.vscode/settings.json

@ -9,6 +9,7 @@
"ldflags",
"LOCALAPPDATA",
"pkill",
"runas",
"setlocal",
"taskkill",
"trimpath"

BIN
app.exe

11
app.manifest

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="app" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

BIN
cursor-id-modifier-linux

BIN
cursor-id-modifier-macos

12
go.mod

@ -1,11 +1,13 @@
module github.com/yuaotian/go-cursor-help
module cursor-id-modifier
go 1.22.0
go 1.21
require github.com/fatih/color v1.18.0
require (
github.com/fatih/color v1.15.0
golang.org/x/sys v0.13.0
)
require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/sys v0.28.0
github.com/mattn/go-isatty v0.0.17 // indirect
)

15
go.sum

@ -1,13 +1,10 @@
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

9
install.sh

@ -16,15 +16,14 @@ detect_platform() {
case "$OS" in
linux*)
case "$ARCH" in
x86_64) BINARY_NAME="cursor-id-modifier" ;;
aarch64) BINARY_NAME="cursor-id-modifier-arm64" ;;
x86_64) BINARY_NAME="cursor_id_modifier_v2.0.0_linux_amd64" ;;
*) error "Unsupported Linux architecture/不支持的Linux架构: $ARCH" ;;
esac
;;
darwin*)
case "$ARCH" in
x86_64) BINARY_NAME="cursor-id-modifier-amd64" ;;
arm64) BINARY_NAME="cursor-id-modifier-arm64" ;;
x86_64) BINARY_NAME="cursor_id_modifier_v2.0.0_mac_intel" ;;
arm64) BINARY_NAME="cursor_id_modifier_v2.0.0_mac_m1" ;;
*) error "Unsupported macOS architecture/不支持的macOS架构: $ARCH" ;;
esac
;;
@ -47,7 +46,7 @@ INSTALL_DIR="/usr/local/bin"
# Download binary / 下载二进制文件
echo "Downloading cursor-id-modifier for/正在下载 $OS ($ARCH)..."
TEMP_DIR=$(mktemp -d)
DOWNLOAD_URL="https://github.com/yuaotian/go-cursor-help/releases/latest/download/$BINARY_NAME"
DOWNLOAD_URL="https://github.com/yuaotian/go-cursor-help/raw/main/bin/$BINARY_NAME"
if ! curl -fsSL "$DOWNLOAD_URL" -o "$TEMP_DIR/$BINARY_NAME"; then
error "Failed to download binary/下载二进制文件失败"

113
main.go

@ -15,7 +15,6 @@ import (
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
"github.com/fatih/color"
@ -28,23 +27,23 @@ type Language string
const (
CN Language = "cn"
EN Language = "en"
// Version constant
Version = "1.0.1"
)
// TextResource 存储多语言文本 / TextResource stores multilingual text
type TextResource struct {
SuccessMessage string
RestartMessage string
ReadingConfig string
GeneratingIds string
PressEnterToExit string
ErrorPrefix string
PrivilegeError string
RunAsAdmin string
RunWithSudo string
SudoExample string
SuccessMessage string
RestartMessage string
ReadingConfig string
GeneratingIds string
PressEnterToExit string
ErrorPrefix string
PrivilegeError string
RunAsAdmin string
RunWithSudo string
SudoExample string
}
// StorageConfig 优化的存储配置结构 / StorageConfig optimized storage configuration struct
@ -76,28 +75,28 @@ var (
texts = map[Language]TextResource{
CN: {
SuccessMessage: "[√] 配置文件已成功更新!",
RestartMessage: "[!] 请手动重启 Cursor 以使更新生效",
ReadingConfig: "正在读取配置文件...",
GeneratingIds: "正在生成新的标识符...",
PressEnterToExit: "按回车键退出程序...",
ErrorPrefix: "程序发生严重错误: %v",
PrivilegeError: "\n[!] 错误:需要管理员权限",
RunAsAdmin: "请右键点击程序,选择「以管理员身份运行」",
RunWithSudo: "请使用 sudo 命令运行此程序",
SudoExample: "示例: sudo %s",
SuccessMessage: "[√] 配置文件已成功更新!",
RestartMessage: "[!] 请手动重启 Cursor 以使更新生效",
ReadingConfig: "正在读取配置文件...",
GeneratingIds: "正在生成新的标识符...",
PressEnterToExit: "按回车键退出程序...",
ErrorPrefix: "程序发生严重错误: %v",
PrivilegeError: "\n[!] 错误:需要管理员权限",
RunAsAdmin: "请右键点击程序,选择「以管理员身份运行」",
RunWithSudo: "请使用 sudo 命令运行此程序",
SudoExample: "示例: sudo %s",
},
EN: {
SuccessMessage: "[√] Configuration file updated successfully!",
RestartMessage: "[!] Please restart Cursor manually for changes to take effect",
ReadingConfig: "Reading configuration file...",
GeneratingIds: "Generating new identifiers...",
PressEnterToExit: "Press Enter to exit...",
ErrorPrefix: "Program encountered a serious error: %v",
PrivilegeError: "\n[!] Error: Administrator privileges required",
RunAsAdmin: "Please right-click and select 'Run as Administrator'",
RunWithSudo: "Please run this program with sudo",
SudoExample: "Example: sudo %s",
SuccessMessage: "[√] Configuration file updated successfully!",
RestartMessage: "[!] Please restart Cursor manually for changes to take effect",
ReadingConfig: "Reading configuration file...",
GeneratingIds: "Generating new identifiers...",
PressEnterToExit: "Press Enter to exit...",
ErrorPrefix: "Program encountered a serious error: %v",
PrivilegeError: "\n[!] Error: Administrator privileges required",
RunAsAdmin: "Please right-click and select 'Run as Administrator'",
RunWithSudo: "Please run this program with sudo",
SudoExample: "Example: sudo %s",
},
}
)
@ -224,9 +223,9 @@ func killCursorProcesses() error {
// First try graceful shutdown
exec.Command("taskkill", "/IM", "Cursor.exe").Run()
exec.Command("taskkill", "/IM", "cursor.exe").Run()
time.Sleep(time.Second)
// Force kill any remaining instances
exec.Command("taskkill", "/F", "/IM", "Cursor.exe").Run()
exec.Command("taskkill", "/F", "/IM", "cursor.exe").Run()
@ -244,7 +243,7 @@ func checkCursorRunning() bool {
} else {
cmd = exec.Command("pgrep", "-f", "Cursor")
}
output, _ := cmd.Output()
return strings.Contains(string(output), "Cursor") || strings.Contains(string(output), "cursor")
}
@ -288,7 +287,7 @@ func printCyberpunkBanner() {
cyan.Println(banner)
yellow.Println("\t\t>> Cursor ID Modifier v1.0 <<")
magenta.Println("\t\t [ By Pancake Fruit Rolled Shark Chili ]")
langText := "当前语言/Language: "
if currentLanguage == CN {
langText += "简体中文"
@ -302,7 +301,7 @@ func showSuccess() {
text := texts[currentLanguage]
successColor := color.New(color.FgGreen, color.Bold)
warningColor := color.New(color.FgYellow, color.Bold)
successColor.Printf("\n%s\n", text.SuccessMessage)
warningColor.Printf("%s\n", text.RestartMessage)
}
@ -311,7 +310,7 @@ func showPrivilegeError() {
text := texts[currentLanguage]
red := color.New(color.FgRed, color.Bold)
yellow := color.New(color.FgYellow)
red.Println(text.PrivilegeError)
if runtime.GOOS == "windows" {
yellow.Println(text.RunAsAdmin)
@ -324,16 +323,16 @@ func showPrivilegeError() {
func showIdComparison(oldConfig *StorageConfig, newConfig *StorageConfig) {
cyan := color.New(color.FgCyan)
yellow := color.New(color.FgYellow)
fmt.Println("\n=== ID Modification Comparison / ID 修改对比 ===")
if oldConfig != nil {
cyan.Println("\n[Original IDs / 原始 ID]")
yellow.Printf("Machine ID: %s\n", oldConfig.TelemetryMachineId)
yellow.Printf("Mac Machine ID: %s\n", oldConfig.TelemetryMacMachineId)
yellow.Printf("Dev Device ID: %s\n", oldConfig.TelemetryDevDeviceId)
}
cyan.Println("\n[Newly Generated IDs / 新生成 ID]")
yellow.Printf("Machine ID: %s\n", newConfig.TelemetryMachineId)
yellow.Printf("Mac Machine ID: %s\n", newConfig.TelemetryMacMachineId)
@ -395,7 +394,7 @@ func loadAndUpdateConfig() (*StorageConfig, error) {
text := texts[currentLanguage]
showProgress(text.ReadingConfig)
_, err = os.ReadFile(configPath)
if err != nil && !os.IsNotExist(err) {
return nil, &AppError{"read config file", configPath, err}
@ -413,14 +412,14 @@ func checkAdminPrivileges() (bool, error) {
cmd := exec.Command("net", "session")
err := cmd.Run()
return err == nil, nil
case "darwin", "linux":
currentUser, err := user.Current()
if err != nil {
return false, fmt.Errorf("failed to get current user: %v", err)
}
return currentUser.Uid == "0", nil
default:
return false, fmt.Errorf("unsupported operating system: %s", runtime.GOOS)
}
@ -432,16 +431,16 @@ func selfElevate() error {
if err != nil {
return err
}
cwd, err := os.Getwd()
if err != nil {
return err
}
verbPtr, _ := syscall.UTF16PtrFromString(verb)
exePtr, _ := syscall.UTF16PtrFromString(exe)
cwdPtr, _ := syscall.UTF16PtrFromString(cwd)
argPtr, _ := syscall.UTF16PtrFromString("")
// 将字符串转换为UTF-16指针
verbPtr, _ := windows.UTF16PtrFromString(verb)
exePtr, _ := windows.UTF16PtrFromString(exe)
cwdPtr, _ := windows.UTF16PtrFromString(cwd)
argPtr, _ := windows.UTF16PtrFromString("")
var showCmd int32 = 1 //SW_NORMAL
@ -460,7 +459,7 @@ func detectLanguage() Language {
if lang == "" {
lang = os.Getenv("LANGUAGE")
}
if strings.Contains(strings.ToLower(lang), "zh") {
return CN
}
@ -494,7 +493,7 @@ func main() {
os.Stdout.Sync()
currentLanguage = detectLanguage()
isAdmin, err := checkAdminPrivileges()
if err != nil {
handleError("permission check failed", err)
@ -524,7 +523,7 @@ func main() {
waitExit()
return
}
time.Sleep(2 * time.Second)
if checkCursorRunning() {
fmt.Println("\nWarning: Cursor is still running. Please close it manually. / 警告:Cursor 仍在运行,请手动关闭。")
@ -535,21 +534,21 @@ func main() {
clearScreen()
printCyberpunkBanner()
oldConfig, err := readExistingConfig()
if err != nil {
oldConfig = nil
}
config, err := loadAndUpdateConfig()
if err != nil {
handleError("configuration update failed", err)
waitExit()
return
}
showIdComparison(oldConfig, config)
if err := saveConfig(config); err != nil {
handleError("failed to save configuration", err)
waitExit()

Loading…
Cancel
Save