aboutsummaryrefslogtreecommitdiffhomepage
path: root/params.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-07-03 02:59:43 +0900
committerOphestra <cat@gensokyo.uk>2025-07-03 02:59:43 +0900
commit1b5ecd9eaf3289d164d8ed1bce6013e0e4ef8e86 (patch)
tree047fe5fabdfb37d5c0088f7f572cebc8b13853bb /params.go
parent82561d62b66f17c05604e87f18187bb3a91f00d2 (diff)
container: move out of toplevel
This allows slightly easier use of the vanity url. This also provides some disambiguation between low level containers and hakurei app containers. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'params.go')
-rw-r--r--params.go47
1 files changed, 0 insertions, 47 deletions
diff --git a/params.go b/params.go
deleted file mode 100644
index 47441235..00000000
--- a/params.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package hakurei
-
-import (
- "encoding/gob"
- "errors"
- "os"
- "strconv"
-)
-
-var (
- ErrNotSet = errors.New("environment variable not set")
- ErrInvalid = errors.New("bad file descriptor")
-)
-
-// Setup appends the read end of a pipe for setup params transmission and returns its fd.
-func Setup(extraFiles *[]*os.File) (int, *gob.Encoder, error) {
- if r, w, err := os.Pipe(); err != nil {
- return -1, nil, err
- } else {
- fd := 3 + len(*extraFiles)
- *extraFiles = append(*extraFiles, r)
- return fd, gob.NewEncoder(w), nil
- }
-}
-
-// Receive retrieves setup fd from the environment and receives params.
-func Receive(key string, e any, v **os.File) (func() error, error) {
- var setup *os.File
-
- if s, ok := os.LookupEnv(key); !ok {
- return nil, ErrNotSet
- } else {
- if fd, err := strconv.Atoi(s); err != nil {
- return nil, err
- } else {
- setup = os.NewFile(uintptr(fd), "setup")
- if setup == nil {
- return nil, ErrInvalid
- }
- if v != nil {
- *v = setup
- }
- }
- }
-
- return setup.Close, gob.NewDecoder(setup).Decode(e)
-}