🐹 @file Operator in TuskLang - Go Guide

Go Documentation

@file Operator in TuskLang - Go Guide

πŸ“ File Power: @file Operator Mastery

TuskLang's @file operator is your file system rebellion. We don't bow to any kingβ€”not even the filesystem. Here's how to use @file in Go projects to read, write, and manipulate files directly from your configuration.

πŸ“‹ Table of Contents

- What is @file? - Basic Usage - File Operations - Security Considerations - Go Integration - Best Practices

πŸ“„ What is @file?

The @file operator provides direct file system access from your config. Read files, check existence, get file infoβ€”all without leaving your configuration.

πŸ› οΈ Basic Usage

[files]
ssl_cert: @file.read("ssl/cert.pem")
config_json: @file.read("config.json")
file_exists: @file.exists("important.txt")

πŸ”§ File Operations

Reading Files

[content]
template: @file.read("templates/email.html")
config: @file.read("config.json")
key: @file.read("ssl/private.key")

File Information

[info]
file_size: @file.size("large_file.dat")
file_modified: @file.modified("config.json")
file_exists: @file.exists("required.txt")

Directory Operations

[dirs]
file_count: @file.count("logs/")
file_list: @file.list("configs/")

πŸ”’ Security Considerations

- Use @file.secure for sensitive files - Validate file paths to prevent directory traversal - Set appropriate file permissions - Never read files with user input

πŸ”— Go Integration

sslCert := config.GetString("ssl_cert")
template := config.GetString("template")
fileExists := config.GetBool("file_exists")

Manual File Operations

data, err := os.ReadFile("config.json")
if err != nil {
    log.Fatal(err)
}

info, err := os.Stat("file.txt") if err != nil { log.Fatal(err) }

πŸ₯‡ Best Practices

- Use absolute paths for critical files - Validate file content after reading - Handle file not found errors gracefully - Use file operations sparingly for performance

---

TuskLang: File power at your fingertips with @file.