初始提交: ScriptForge 脚本快速转运行链接服务
Some checks failed
Release / build-and-release (push) Failing after 1m31s
Some checks failed
Release / build-and-release (push) Failing after 1m31s
- Go 后端 (Gin + GORM + SQLite) 提供 API 和纯文本脚本服务 - Vite + React + TypeScript + Tailwind 前端 - 单二进制部署 (Go embed 前端静态文件) - Gitea Actions CI/CD: 打标签自动构建多平台 Release - 支持 bash/zsh/sh/fish/python3/node/ruby/php 8种运行环境 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
37
backend/internal/config/runtime.go
Normal file
37
backend/internal/config/runtime.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package config
|
||||
|
||||
type RuntimeConfig struct {
|
||||
Name string
|
||||
Extension string
|
||||
MIMEType string
|
||||
}
|
||||
|
||||
var Runtimes = []RuntimeConfig{
|
||||
{Name: "bash", Extension: ".sh", MIMEType: "text/x-shellscript"},
|
||||
{Name: "zsh", Extension: ".zsh", MIMEType: "text/x-shellscript"},
|
||||
{Name: "sh", Extension: ".sh", MIMEType: "text/x-shellscript"},
|
||||
{Name: "fish", Extension: ".fish", MIMEType: "text/x-shellscript"},
|
||||
{Name: "python3", Extension: ".py", MIMEType: "text/x-python"},
|
||||
{Name: "node", Extension: ".js", MIMEType: "text/javascript"},
|
||||
{Name: "ruby", Extension: ".rb", MIMEType: "text/x-ruby"},
|
||||
{Name: "php", Extension: ".php", MIMEType: "text/x-php"},
|
||||
}
|
||||
|
||||
var RuntimeMap map[string]RuntimeConfig
|
||||
|
||||
func init() {
|
||||
RuntimeMap = make(map[string]RuntimeConfig, len(Runtimes))
|
||||
for _, rt := range Runtimes {
|
||||
RuntimeMap[rt.Name] = rt
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidRuntime(name string) bool {
|
||||
_, ok := RuntimeMap[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
func GetRuntime(name string) (RuntimeConfig, bool) {
|
||||
rt, ok := RuntimeMap[name]
|
||||
return rt, ok
|
||||
}
|
||||
Reference in New Issue
Block a user