Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "log" "os" "time" awsconfig "github.com/aws/aws-sdk-go-v2/config" "github.com/dwango/yashiro" "github.com/dwango/yashiro/pkg/config" ) func main() { ctx := context.TODO() sdkConfig, err := awsconfig.LoadDefaultConfig(ctx) if err != nil { log.Fatalf("failed to load config: %s", err) } refName := "example" cfg := &config.Config{ Global: config.GlobalConfig{ EnableCache: true, // enable cache Cache: config.CacheConfig{ Type: config.CacheTypeMemory, ExpireDuration: config.Duration(30 * time.Minute), }, }, Aws: &config.AwsConfig{ ParameterStoreValues: []config.AwsParameterStoreValueConfig{ { ValueConfig: config.ValueConfig{ Name: "/example", Ref: &refName, IsJSON: true, }, }, }, SdkConfig: &sdkConfig, }, } eng, err := yashiro.NewEngine(cfg, yashiro.IgnoreNotFound(true)) // ignore not found value if err != nil { log.Fatalf("failed to create engine: %s", err) } text := `This is example code. The message is {{ .example.message }}.` if err := eng.Render(ctx, text, os.Stdout); err != nil { log.Fatalf("failed to render text: %s", err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // NewEngine returns a new Engine. NewEngine = engine.New // IgnoreNotFound is an option to ignore missing external store values. IgnoreNotFound = engine.IgnoreNotFound )
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.