Resources

Resources (pictures, themes, translations, etc.) with which the application works should be placedin subdirectories within one resource directory. Resources should be located in the following subdirectories:

  • images - all images are placed in this subdirectory. Here you can make nested subdirectories.In this case, they must be included in the file name. For example, "subdir/image1.png"
  • themes - application themes are placed in this subdirectory (see below)
  • views - View descriptions are placed in this subdirectory
  • strings - translations of text resources are placed in this subdirectory (see Support for multiple languages)
  • raw - all other resources are placed in this subdirectory: sounds, video, binary data, etc.

The resource directory can either be included in the executable file or located separately.

If the resources need to be included in the executable file, then the name of the directory must be "resources" and it must be connected as follows:

import (
	"embed"
	"github.com/anoshenko/rui"
)
//go:embed resources
var resources embed.FS
func main() {
	rui.AddEmbedResources(&resources)
	
	app := rui.NewApplication("Hello world", createHelloWorldSession)
	app.Start("localhost:8000")
}

If the resources are supplied as a separate directory, then it must be registeredusing the SetResourcePath function before creating the Application:

func main() {
	rui.SetResourcePath(path)
	
	app := rui.NewApplication("Hello world", createHelloWorldSession)
	app.Start("localhost:8000")
}