Could this tiny file really run?
Yes. This exact file runs as a page.
<%@ LANGUAGE="GND.Go.Yaegi" %>
<%
import . "OpenASP"
func run() {
Response.Write("<h1>Hello from Go on GNDLine.</h1>")
}
%>
GNDLine beta4 package
This package bundles the GNDLine web runtime together with Go and modern language engines.
Yes. This exact file runs as a page.
<%@ LANGUAGE="GND.Go.Yaegi" %>
<%
import . "OpenASP"
func run() {
Response.Write("<h1>Hello from Go on GNDLine.</h1>")
}
%>
Yes. This exact file runs as a JSON endpoint.
<%@ LANGUAGE="GND.Go.Yaegi" %>
<%
import . "OpenASP"
func run() {
Response.WriteJSON(map[string]any{
"ok": true,
"message": "Hello from GND.Go.Yaegi via .api",
})
}
%>
The packaged examples cover these core host and page surfaces:
RequestResponseSessionApplicationServerRoutingAuthenticationMultipartJSONThe packaged page examples run on:
Go YaegiOpenVBSThis gallery includes both Page(.asp) examples and JSON API(.api) examples. They run the same way; .api is just a clearer URL shape for endpoint-style routes.
Here, HTML appears inline inside func run().
<%
func run() {
title := "inline sample"
%>
<h1><%= title %></h1>
<%
}
%>
Upload a file here. The page shows its name, size, and a text preview when possible.
This page returns JSON with Response.WriteJSON(...). POST requests are JSON-only.
<%
func run() {
Response.WriteJSON(map[string]any{
"ok": true,
})
}
%>
This page imports a package from GND.Go.Yaegi.vendor and returns JSON.
<%
import "example.com/srcsample"
func run() {
Response.WriteJSON(map[string]any{
"message": srcsample.Message("demo"),
})
}
%>
This page changes session state from a query string.
<%
func run() {
query := Request.QueryString()
Session.Contents().SetItem("LoginState", first(query.Item("mode")))
}
%>
This page reads session state and shows the current login value.
<%
func run() {
loginState := Session.Contents().Item("LoginState")
}
%>
<p>LoginState=<%= loginState %></p>
This page opens SQLite, writes a sample row, and returns JSON.
<%
import "example.com/sqliteapp/store"
func run() {
db, _ := store.Open("sample.db")
Response.WriteJSON(map[string]any{
"ok": true,
})
}
%>
This page adapts BILib.Mail and returns a JSON preview.
<%
import . "BILib"
func run() {
mail, _ := AsMail(Server.CreateObject("BILib.Mail"))
Response.WriteJSON(map[string]any{
"ok": true,
})
}
%>
This global hook stores application-wide values when the app starts.
<script language="GND.Go.Yaegi" runat="server">
func Application_OnStart() {
Application.Lock()
Application.Contents().SetItem("SiteName", "GNDLine Beta Package")
Application.Unlock()
}
</script>
This global hook gives each new session a default login state.
<script language="GND.Go.Yaegi" runat="server">
func Session_OnStart() {
Session.Contents().SetItem("LoginState", "guest")
}
</script>
Install this in global.asa to register routes at app startup.
<script language="GND.Go.Yaegi" runat="server">
import . "OpenASP"
func Application_OnStart() {
router, _ := AsRouter(Server.CreateObject(".Router"))
router.GET("/routed.asp", "/target.asp")
router.GET("/api/*", "/api/json.api")
router.GET("/users/{id}.asp", "/auth/home.asp")
Application.Use(router)
}
</script>
Install this in global.asa to protect routes before page entry.
<script language="GND.Go.Yaegi" runat="server">
import . "OpenASP"
func Application_OnStart() {
auth, _ := AsAuthBySession(Server.CreateObject(".AuthBySession"))
auth.Item("/member/*", "MemberID", "/login.asp")
auth.Item("/admin/*", "AdminID", "/login-admin.asp")
Application.Use(auth)
}
</script>
This page uses classic VBScript-style CreateObject(...).
<%@ LANGUAGE="GND.OpenVBS" %>
<%
set dic = CreateObject("Scripting.Dictionary")
dic("foo") = "bar"
%>
<h1><%= dic("foo") %></h1>
This page calls an OpenVBS function from Go.
<%@ LANGUAGE="GND.Go.Yaegi" %>
<script language="GND.OpenVBS" runat="server">
function GetMessage()
GetMessage = "this is OpenVBS in Go."
end function
</script>
<%
func run() {
message := GetMessage()
Response.Write(message)
}
%>
This page calls a Go function from OpenVBS.
<%@ LANGUAGE="GND.OpenVBS" %>
<script language="GND.Go.Yaegi" runat="server">
func GetMessage() string {
return "this is Go in OpenVBS."
}
</script>
<%
v = GetMessage()
Response.Write v
%>
This page ends with invalid Go on purpose.
<%
func run() {
pageStart("GNDLine 500 Example")
}
this is not valid go
%>
The current package also bundles these object runtimes for OpenVBS page code, plus the optional BILDB plugin.
BILib.MailCompose mail fields and send through an SMTP config bag.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
mail = CreateObject("BILib.Mail")
mail.Subject = "hello"
%>
BILib.DictionaryUse a dictionary object with classic script-style item access.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
dict = CreateObject("BILib.Dictionary")
dict("foo") = "bar"
%>
BILib.RegExpUse a regular-expression object from OpenVBS page code.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
re = CreateObject("BILib.RegExp")
re.Pattern = "foo+"
%>
BILib.HttpRequestUse an HTTP client object from OpenVBS page code.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
req = CreateObject("BILib.HttpRequest")
req.Open "GET", "https://example.com/", False
%>
BILib.StreamUse a byte/text stream object from OpenVBS page code.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
stream = CreateObject("BILib.Stream")
stream.Open
stream.WriteText "hello"
%>
BILDB.ConnectionOptional ODBC database plugin. Requires an external ODBC runtime on the host.
<%@ LANGUAGE="GND.OpenVBS" %>
<%
conn = CreateObject("BILDB.Connection")
conn.Open "Driver=..."
conn("SELECT * FROM TMember WHERE name=?", "jenny").foreach(function(r)
Response.Write r(0).name & ":" & r("id")
Response.Write r(1).name & ":" & r("name")
Response.Write r(2).name & ":" & r("time")
end function)
%>