Background: This repository contains useful github-related content for the Keyfactor organization. It is public for a mixture of convenience and transparency.
- Follow good practices: Reusable, documented, etc.
- Do not reinvent the wheel; Where there is an appropriate library to do the work, use it.
- Assume you are likely wrong and ask for clarification on any aspect which is not already explicitly described to you.
All Python scripts should be built around using uv. The most basic script is
#!/usr/bin/env uv run
#/// script
# requirements: []
#///
def main():
pass
if __name__ == "__main__":
main()When writing HTML, prefer using CSS over inline styles. Do not play div-golf. Do not nest divs inside divs without reason.
When writing Go,
- Follow the Go style guide from Google with the specific exception that parameter names should be multiple characters long, loop variables should be reasonably descriptive, and comments should be shorter.
- Look for libraries that solve a problem before writing things from first principles
- When using tools, use
go get -tool <package>rather thango get -u <package>and then call that tool usinggo tool <toolname>.
Avoid using Make. Update where make is currently in use, but do not create new Makefiles unless explictly directed to. Use Just instead.
Include at the beginning the following recipe:
set windows-shell := ['pwsh', '-c']
# list recipies.
_default:
@just --listWherever you write shell scripts:
- if it is only UNIX applicable, write only a standard shell script. use
set -uexo pipefailto strengthen scripts. - if it is applicable to both UNIX and Windows, either write both Shell and Powershell scripts (if it is shorter than 10 lines or so) or write explicitly in Powershell (if it is longer or simpler to use Powershell)
- Always use
set -uexo pipefail - Avoid bashishms. Use as POSIX compliant shell as you can. Where you must, you can use Debian's tricks to avoid bashisms (e.g.
if [ "x$FOO" -eq "x"]to determine if an environment variable is set) - be EXTREMELY cautious. Do NOT build complicated pipe trains.
Expect Powershell 7. Be sure to include any library calls you need. Prefer to use builtins first. Don't assume all Powershell is Windows.