package main

import (
	"embed"
	"fmt"
	"io/fs"
)

// Embed a single file as a string
//
//go:embed version.txt
var version string

// Embed a single file as bytes
//
//go:embed config.json
var configData []byte

// Embed multiple files using embed.FS
//
//go:embed templates/*
var templates embed.FS

func main() {
	// Using embedded string
	fmt.Println("Version:", version)

	// Using embedded bytes
	fmt.Println("\nConfig Data:")
	fmt.Println(string(configData))

	// Using embedded filesystem
	fmt.Println("Template Files:")
	fs.WalkDir(templates, ".", func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}
		if !d.IsDir() {
			fmt.Printf("  - %s\n", path)
		}
		return nil
	})

	// Read a specific embedded file
	content, _ := templates.ReadFile("templates/hello.html")
	fmt.Println("\nhello.html content:")
	fmt.Println(string(content))
}
