Download internal/bootstrap/data/dev.go from lin7zhi/OpenList: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/lin7zhi/OpenList/resolve/main/internal/bootstrap/data/dev.go
- Command line
-
hf download hf://spaces/lin7zhi/OpenList/internal/bootstrap/data/dev.go
-
curl -L -o dev.go https://huggingface.co/spaces/lin7zhi/OpenList/resolve/main/internal/bootstrap/data/dev.go
1.2 kB
| package data | |
| import ( | |
| "context" | |
| "github.com/OpenListTeam/OpenList/v4/cmd/flags" | |
| "github.com/OpenListTeam/OpenList/v4/internal/db" | |
| "github.com/OpenListTeam/OpenList/v4/internal/message" | |
| "github.com/OpenListTeam/OpenList/v4/internal/model" | |
| "github.com/OpenListTeam/OpenList/v4/internal/op" | |
| log "github.com/sirupsen/logrus" | |
| ) | |
| func initDevData() { | |
| _, err := op.CreateStorage(context.Background(), model.Storage{ | |
| MountPath: "/", | |
| Order: 0, | |
| Driver: "Local", | |
| Status: "", | |
| Addition: `{"root_folder_path":"."}`, | |
| }) | |
| if err != nil { | |
| log.Fatalf("failed to create storage: %+v", err) | |
| } | |
| err = db.CreateUser(&model.User{ | |
| Username: "Noah", | |
| Password: "hsu", | |
| BasePath: "/data", | |
| Role: 0, | |
| Permission: 512, | |
| }) | |
| if err != nil { | |
| log.Fatalf("failed to create user: %+v", err) | |
| } | |
| } | |
| func initDevDo() { | |
| if flags.Dev { | |
| go func() { | |
| err := message.GetMessenger().WaitSend(message.Message{ | |
| Type: "string", | |
| Content: "dev mode", | |
| }, 10) | |
| if err != nil { | |
| log.Debugf("%+v", err) | |
| } | |
| m, err := message.GetMessenger().WaitReceive(10) | |
| if err != nil { | |
| log.Debugf("%+v", err) | |
| } else { | |
| log.Debugf("received: %+v", m) | |
| } | |
| }() | |
| } | |
| } | |