Conduit (noun.): a channel or pipe used to convey something, such as water, electrical wires, or information
Conduit is a channel for your variables across languages.
go install github.com/kikikian/conduit@latestPolyglot projects make you duplicate constants. A port number lives in your Go server, your Python script, and your TypeScript frontend. That is three places to keep in sync, three places to get wrong.
Conduit fixes that. define a variable once and it automatically appears in every language you use, with the right type.
-> Golang
-> Python
-> Typesript
# 1. initialize your project
conduit init
# 2. add a variable
conduit add --name PORT --type int --value 3000
# 3. start watching
conduit watchConduit monitors .conduit and rewrites your target files every time a variable changes.
Mark the spot in your code where you want a variable injected:
python
# conduit:import PORTtypescript
// conduit:import PORTgo
// conduit:import PORTWhen conduit runs, those lines become typed declarations:
PORT: int = 3000const PORT: number = 3000var PORT int = 3000conduit init
Select your target languages and map them to file paths -> creates conduit.config.json.
conduit add
Add a variable. Interactive or via flags:
conduit add --name DATABASE_URL --type string --value postgresql://localhost/mydb
conduit add --name DEBUG --type bool --value true
conduit add --name PORT --type int --value 5432conduit watch
Watch .conduit for changes and regenerate all target files instantly. Run this in the background while you develop.
conduit watch
conduit watch --file python:./app.py # one-off override| conduit | python | typescript | go |
|---|---|---|---|
int |
int |
number |
int |
string |
str |
string |
string |
bool |
bool |
boolean |
bool |
conduit init generates a conduit.config.json in your project root:
{
"targets": [
{ "lang": "python", "filePath": "./app.py" },
{ "lang": "typescript", "filePath": "./src/config.ts" },
{ "lang": "go", "filePath": "./pkg/config.go" }
]
}| file | purpose |
|---|---|
.conduit |
stores all variable definitions |
conduit.config.json |
maps languages to target files |
git clone https://github.com/kikikian/conduit.git
cd conduit
go build