oxfeeefeee / goscript Goto Github PK
View Code? Open in Web Editor NEWAn alternative implementation of Golang specs, written in Rust for embedding or wrapping.
License: Other
An alternative implementation of Golang specs, written in Rust for embedding or wrapping.
License: Other
Invalid discord invite
The Dot import syntax brings the entire package into the current namespace. So, you don’t have to call the functions using the package name. You can directly call them.
package main
import (
. "fmt2"
)
func main() {
Println("Hello, World!")
}
That it would print out "Hello, World!"
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ...goscript/codegen/src/package.rs:47:60
Hello! Wonderful project. I was playing around with embedded structs as they're a golang feature I quite like, and I found that fields and methods aren't promoted in goscript like they are in golang proper:
package main
import (
"fmt"
)
type Base struct {
name string
}
func (b Base) PrintField() {
fmt.Println(b.name)
}
type Container struct {
Base
}
func main() {
t := Container{Base{"go"}}
//t.PrintField() //error in goscript, but works in golang
t.Base.PrintField() //have to use this instead
}
I'm not sure if this is an issue with the go specs, or simply this implementation. I'm not even sure if implementing field promotion is on the table. But I felt it was worth bringing up anyway.
The error specifically when trying to run this script is:
thread 'main' panicked at 'no entry found for key', ...\vm\src\metadata.rs:493:9
so it seems to be an error with field name resolution.
The Chinese character "非" (non-) has to be added directly to "官方" (official) to mean "non-official," so it shoud be "Go语言规范的非官方实现" instead of "Go语言规范非的官方实现."
I don't know if this was intentional, but on the registered-based
branch, creating a map was possible from ffi.
How do I do this while using the master branch? The new_map
function is only available within goscript crate.
Line 1492 in 04d1cb0
I am working from the register-based
library, because that is where I have managed to use the FFI API extensively. But I am having a type conversion problem
I have this go script file
package main
import (
"zflow"
"fmt2"
)
var in = zflow.Inputs() // this returns map[string]interface{} type
func main() {
fmt2.Println(in) // this prints map[left:1 right:2]
// get inputs
data, ok := in.(map[string]interface{})
fmt2.Println(ok) // this prints false
fmt2.Println(data) // this prints <nil(map)>
left := data["left"]
fmt2.Println(left) // this prints <nil>
}
Output:
map[right:2 left:1]
false
<nil(map)>
<nil>
Expected output
https://go.dev/play/p/qPNzh1RmyiQ
map[left:1 right:2]
true
map[left:1 right:2]
2
How do I correctly read a map value that is sent into the runtime via FFI function call?
Is there a reason why ffi is not public?
Line 13 in d62291d
This section of the code loops infinitely with input `
.
#[test]
fn test() {
let mut fs = fe::FileSet::new();
let o = &mut fe::objects::Objects::new();
let el = &mut fe::errors::ErrorList::new();
parse_file(o, &mut fs, el, "/a", "`", false);
}
Unwrapping b.as_ref()
is not guaranteed, and fails sometimes when you pass an interface{} value into an ffi function.
Line 1843 in 04d1cb0
I wonder what the general behavior would be if you applied this as a fix
let want_meta = want_meta.as_metadata();
if b.is_none() {
return Ok((want_meta.zero(metas, gcc), false));
}
let meta = b.as_ref().unwrap().0;
Sample:
package main
func broken(elems ...int) {}
func main() {
broken()
}
thread 'test_std_temp' panicked at 'index out of bounds: the len is 0 but the index is 0', codegen/src/codegen.rs:965:32
This is a pretty amazing project, thanks for putting it out there :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.