Add os.arch and os.platform (#437)

* add  and

* .ignore
This commit is contained in:
lack 2024-02-24 21:24:35 +08:00 committed by GitHub
parent e9b03930ce
commit 47062da36a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

4
.gitignore vendored
View file

@ -1 +1,3 @@
dist/
dist/
.idea

View file

@ -6,6 +6,8 @@ os := import("os")
## Constants
- `platform`
- `arch`
- `o_rdonly`
- `o_wronly`
- `o_rdwr`

View file

@ -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)},