From: Nadav Har'El <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master

Go application example, using golang

This is a trivial "hello world" application in Go, which we compile with
the traditional golang compiler (see the separate gccgo-example app for
an example with the gccgo compiler).

This example does *not* yet work at this stage, but it is useful to have
a common ground for discussion on Go support in OSv.

I used the new "c-shared" build mode of golang. I don't know if it the
right thing to use but it sounds a reasonable start (I'll try later other
modes to see if they give better results).

Signed-off-by: Nadav Har'El <[email protected]>

---
diff --git a/golang-example/Makefile b/golang-example/Makefile
--- a/golang-example/Makefile
+++ b/golang-example/Makefile
@@ -0,0 +1,9 @@
+.PHONY: module
+module: hello
+       echo '/hello: $${MODULE_DIR}/hello' > usr.manifest
+
+hello: hello.go
+       /usr/lib/golang/bin/go build -buildmode=c-shared hello.go
+
+clean:
+       rm -f hello usr.manifest
diff --git a/golang-example/hello.go b/golang-example/hello.go
--- a/golang-example/hello.go
+++ b/golang-example/hello.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+        "runtime"
+        "fmt"
+)
+
+func main() {
+       fmt.Println("Hello, 世界");
+       fmt.Println("Go version:", runtime.Version());
+}
diff --git a/golang-example/module.py b/golang-example/module.py
--- a/golang-example/module.py
+++ b/golang-example/module.py
@@ -0,0 +1,3 @@
+from osv.modules import api
+
+default = api.run(cmdline="/hello")

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to