pkl-go-examples

module
v0.0.0-...-25085cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0

README

pkl-go-example

This is a sample project that demonstrates Pkl <> Go integration.

This is a basic HTTP server that is configured via Pkl in the pkl/ directory.

Requirements

  • Go >1.18
  • Pkl >0.25.0

Project structure

Directory Description
pkl/ Pkl configuration sources
gen/ Generated Go sources from Pkl
internal/ Internal Go files
cmd/ Server entrypoint
scripts/ Scripts directory

Codegen

To generate new Pkl sources for the AppConfig module, first install the Go code generator:

go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest

With that installed, generate Go sources via:

pkl-gen-go pkl/AppConfig.pkl

The code generator detects that the Go package for AppConfig is github.com/apple/pkl-go-example/gen/appconfig, and the Go module name is github.com/apple/pkl-go-example (via the go.mod file), and therefore places generated sources in gen/appconfig.

Directories

Path Synopsis
===----------------------------------------------------------------------===// Copyright © 2024 Apple Inc.
===----------------------------------------------------------------------===// Copyright © 2024 Apple Inc.
gen
appconfig
Code generated from Pkl module `org.pkl.golang.example.AppConfig`.
Code generated from Pkl module `org.pkl.golang.example.AppConfig`.
appconfig/loglevel
Code generated from Pkl module `org.pkl.golang.example.AppConfig`.
Code generated from Pkl module `org.pkl.golang.example.AppConfig`.
redisconfig
Code generated from Pkl module `org.pkl.golang.example.RedisConfig`.
Code generated from Pkl module `org.pkl.golang.example.RedisConfig`.
===----------------------------------------------------------------------===// Copyright © 2024 Apple Inc.
===----------------------------------------------------------------------===// Copyright © 2024 Apple Inc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL