Repository: maxence-charriere/go-app (language: go)

Issue:
Unused functions reported by staticcheck
v10.0.10: staticcheck reports there are unused functions in

- docs/src/snipets/start.go
- pkg/app/component_test.go
- pkg/app/storage_test.go
- pkg/app/strings.go



Discussion / hints:

Fix patch:
diff --git a/docs/src/snipets/start.go b/docs/src/snipets/start.go
deleted file mode 100644
index 29d3f74d..00000000
--- a/docs/src/snipets/start.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package main
-
-import (
-	"io"
-	"log"
-	"net/http"
-
-	"github.com/maxence-charriere/go-app/v10/pkg/app"
-)
-
-// hello is a component that displays a simple "Hello World!". A component is a
-// customizable, independent, and reusable UI element. It is created by
-// embedding app.Compo into a struct.
-type hello struct {
-	app.Compo
-}
-
-// The Render method is where the component appearance is defined. Here, a
-// "Hello World!" is displayed as a heading.
-func (h *hello) Render() app.UI {
-	return app.H1().Text("Hello World!")
-}
-
-// The main function is the entry point where the app is configured and started.
-// It is executed on 2 different environments: A client (the web browser) and a
-// server.
-func main() {
-	// The first thing to do is to associate the hello component with a path.
-	//
-	// This is done by calling the Route() function,  which tells go-app what
-	// component to display for a given path, on both client and server-side.
-	app.Route("/", app.NewZeroComponentFactory(&hello{}))
-
-	// Once the routes set up, the next thing to do is to either launch the app
-	// or the server that serves the app.
-	//
-	// When executed on the client-side, the RunWhenOnBrowser() function
-	// launches the app,  starting a loop that listens for app events and
-	// executes client instructions. Since it is a blocking call, the code below
-	// it will never be executed.
-	//
-	// On the server-side, RunWhenOnBrowser() does nothing, which allows the
-	// writing of server logic without needing precompiling instructions.
-	app.RunWhenOnBrowser()
-
-	// Finally, launching the server that serves the app is done by using the Go
-	// standard HTTP package.
-	//
-	// The Handler is an HTTP handler that serves the client and all its
-	// required resources to make it work into a web browser. Here it is
-	// configured to handle requests with a path that starts with "/".
-	http.Handle("/", &app.Handler{
-		Name:        "Hello",
-		Description: "An Hello World! example",
-	})
-
-	if err := http.ListenAndServe(":8000", nil); err != nil {
-		log.Fatal(err)
-	}
-}
-
-type foo struct {
-	app.Compo
-
-	response []byte
-}
-
-func (f *foo) OnNav(ctx app.Context) {
-	// Launching a new goroutine:
-	ctx.Async(func() {
-		r, err := http.Get("/bar")
-		if err != nil {
-			app.Log(err)
-			return
-		}
-		defer r.Body.Close()
-
-		b, err := io.ReadAll(r.Body)
-		if err != nil {
-			app.Log(err)
-			return
-		}
-
-		// Storing HTTP response in component field:
-		ctx.Dispatch(func(app.Context) {
-			f.response = b
-		})
-	})
-}
diff --git a/pkg/app/strings.go b/pkg/app/strings.go
index 764a608c..0b1422c3 100644
--- a/pkg/app/strings.go
+++ b/pkg/app/strings.go
@@ -3,7 +3,6 @@ package app
 import (
 	"encoding/json"
 	"fmt"
-	"io"
 	"reflect"
 	"strconv"
 	"strings"
@@ -51,12 +50,6 @@ func toPath(v ...any) string {
 	return b.String()
 }
 
-func writeIndent(w io.Writer, indent int) {
-	for i := 0; i < indent*2; i++ {
-		io.WriteString(w, " ")
-	}
-}
-
 func stringTo(s string, v any) error {
 	val := reflect.ValueOf(v)
 


Test patch:
diff --git a/pkg/app/component_test.go b/pkg/app/component_test.go
index 8eec8ceb..f57ddccf 100644
--- a/pkg/app/component_test.go
+++ b/pkg/app/component_test.go
@@ -137,23 +137,6 @@ func (c *compoWithCustomRoot) Render() UI {
 	return c.Root
 }
 
-type updateNotifierCompo struct {
-	Compo
-	Root   UI
-	notify bool
-}
-
-func (c *updateNotifierCompo) NotifyUpdate() bool {
-	return c.notify
-}
-
-func (c *updateNotifierCompo) Render() UI {
-	if c.Root != nil {
-		return c.Root
-	}
-	return Span()
-}
-
 type navigatorComponent struct {
 	Compo
 
diff --git a/pkg/app/storage_test.go b/pkg/app/storage_test.go
index 58c4ebd6..bbe03a5b 100644
--- a/pkg/app/storage_test.go
+++ b/pkg/app/storage_test.go
@@ -1,7 +1,6 @@
 package app
 
 import (
-	"fmt"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -143,27 +142,6 @@ func testBrowserStorageGetError(t *testing.T, s BrowserStorage) {
 	require.Error(t, err)
 }
 
-func testBrowserStorageFull(t *testing.T, s BrowserStorage) {
-	testSkipNonWasm(t)
-
-	var err error
-	data := make([]byte, 4096)
-	i := 0
-
-	for {
-		key := fmt.Sprintf("/key_%d", i)
-
-		if err = s.Set(key, data); err != nil {
-			break
-		}
-
-		i++
-	}
-
-	require.Error(t, err)
-	t.Log(err)
-}
-
 func testBrowserStorageLen(t *testing.T, s BrowserStorage) {
 	s.Clear()