]> git.giacomolli.uk - onechat/blobdiff - routes.go
Separate multiline Go statements
[onechat] / routes.go
index 7dce691ee0bd657e4c35c7bf8cde035d834588dd..6d72898196d7a4ab0fc5b04e7840ded2e1d9bc27 100644 (file)
--- a/routes.go
+++ b/routes.go
@@ -13,6 +13,16 @@ import (
        "go.mau.fi/whatsmeow/types"
 )
 
        "go.mau.fi/whatsmeow/types"
 )
 
+// Routes owns the root's source map. Writes replace the private file before
+// changing the map in memory. The mutex protects reads and writes from tools
+// and status commands. Logs omit source IDs, which can hold phone numbers.
+type Routes struct {
+       mutex   sync.Mutex
+       path    string
+       logger  *slog.Logger
+       targets map[string]string
+}
+
 // openRoutes reads the source-to-child map. A missing file has no routes.
 func openRoutes(path string, logger *slog.Logger) (*Routes, error) {
        r := &Routes{
 // openRoutes reads the source-to-child map. A missing file has no routes.
 func openRoutes(path string, logger *slog.Logger) (*Routes, error) {
        r := &Routes{
@@ -20,6 +30,7 @@ func openRoutes(path string, logger *slog.Logger) (*Routes, error) {
                logger:  logger,
                targets: make(map[string]string),
        }
                logger:  logger,
                targets: make(map[string]string),
        }
+
        data, err := os.ReadFile(path)
        if errors.Is(err, os.ErrNotExist) {
                return r, nil
        data, err := os.ReadFile(path)
        if errors.Is(err, os.ErrNotExist) {
                return r, nil
@@ -52,16 +63,6 @@ func openRoutes(path string, logger *slog.Logger) (*Routes, error) {
        return r, nil
 }
 
        return r, nil
 }
 
-// Routes owns the root's source map. Writes replace the private file before
-// changing the map in memory. The mutex protects reads and writes from tools
-// and status commands. Logs omit source IDs, which can hold phone numbers.
-type Routes struct {
-       mutex   sync.Mutex
-       path    string
-       logger  *slog.Logger
-       targets map[string]string
-}
-
 // Set maps source to a child name, or removes it when target is empty. The
 // caller checks that a nonempty target is a child of the root.
 func (r *Routes) Set(source, target string) error {
 // Set maps source to a child name, or removes it when target is empty. The
 // caller checks that a nonempty target is a child of the root.
 func (r *Routes) Set(source, target string) error {