From 47062da36aa66b37002bcc60ee5b2d3c8b4045e1 Mon Sep 17 00:00:00 2001 From: lack <598223084@qq.com> Date: Sat, 24 Feb 2024 21:24:35 +0800 Subject: [PATCH] Add `os.arch` and `os.platform` (#437) * add and * .ignore --- .gitignore | 4 +++- docs/stdlib-os.md | 2 ++ stdlib/os.go | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7773828..37eb85e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -dist/ \ No newline at end of file +dist/ + +.idea \ No newline at end of file diff --git a/docs/stdlib-os.md b/docs/stdlib-os.md index fec5d67..dadc5a6 100644 --- a/docs/stdlib-os.md +++ b/docs/stdlib-os.md @@ -6,6 +6,8 @@ os := import("os") ## Constants +- `platform` +- `arch` - `o_rdonly` - `o_wronly` - `o_rdwr` diff --git a/stdlib/os.go b/stdlib/os.go index 576bc94..5af4b60 100644 --- a/stdlib/os.go +++ b/stdlib/os.go @@ -6,11 +6,14 @@ import ( "io/ioutil" "os" "os/exec" + "runtime" "github.com/d5/tengo/v2" ) var osModule = map[string]tengo.Object{ + "platform": &tengo.String{Value: runtime.GOOS}, + "arch": &tengo.String{Value: runtime.GOARCH}, "o_rdonly": &tengo.Int{Value: int64(os.O_RDONLY)}, "o_wronly": &tengo.Int{Value: int64(os.O_WRONLY)}, "o_rdwr": &tengo.Int{Value: int64(os.O_RDWR)},