- Implements all placeholder Go examples in the `examples` directory. - Corrects the `run_matrix_programmatically` example to use the `borg` package. - Refactors the code to centralize the matrix execution logic in the `matrix` package. - Updates the documentation to include a new "Programmatic Usage" section that describes all of the Go examples. - Updates the "Terminal Isolation Matrix" section to remove manual 'runc' instructions, emphasizing that 'borg run' handles this process to maintain security and isolation. - Adds missing examples for 'collect github repos', 'collect github release', and 'compile' commands to the documentation.
42 lines
873 B
Go
42 lines
873 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/Snider/Borg/pkg/compress"
|
|
"github.com/Snider/Borg/pkg/tarfs"
|
|
)
|
|
|
|
func main() {
|
|
log.Println("Serving datanode...")
|
|
|
|
// Create a dummy datanode for serving.
|
|
err := os.WriteFile("serve.dat", []byte{}, 0644)
|
|
if err != nil {
|
|
log.Fatalf("Failed to create dummy datanode: %v", err)
|
|
}
|
|
|
|
data, err := os.ReadFile("serve.dat")
|
|
if err != nil {
|
|
log.Fatalf("Failed to read datanode: %v", err)
|
|
}
|
|
|
|
decompressed, err := compress.Decompress(data)
|
|
if err != nil {
|
|
log.Fatalf("Failed to decompress datanode: %v", err)
|
|
}
|
|
|
|
fs, err := tarfs.New(decompressed)
|
|
if err != nil {
|
|
log.Fatalf("Failed to create tarfs: %v", err)
|
|
}
|
|
|
|
http.Handle("/", http.FileServer(fs))
|
|
log.Println("Listening on :8080...")
|
|
err = http.ListenAndServe(":8080", nil)
|
|
if err != nil {
|
|
log.Fatalf("Failed to start server: %v", err)
|
|
}
|
|
}
|