-
Notifications
You must be signed in to change notification settings - Fork 1
Closed as not planned
Description
From chatgpt
Yes, you can dynamically pull the Go version from a go.mod file and display it in your README.md file by using a simple script that reads the version from go.mod and updates README.md. Here’s a basic example using a shell script to automate this.
1. Create a Shell Script
Create a script, for example, called update-readme.sh:
#!/bin/bash
# Extract the Go version from go.mod
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
# Update README.md by replacing the placeholder or existing Go version
sed -i "" -e "s/Go Version: .*/Go Version: $GO_VERSION/" README.mdThis script:
- Reads the Go version from
go.mod. - Updates
README.mdby finding a line containing "Go Version:" and replacing it with the current Go version.
2. Use a Placeholder in README.md
In your README.md, set up a placeholder like this:
# Project Title
This project uses:
- **Go Version:** [dynamically set here]Run the script to replace [dynamically set here] with the actual version.
3. Automate the Update
To keep this up-to-date, you can add the script as a part of your build or CI pipeline, or run it manually whenever you update go.mod.
Let me know if you’d like to automate this further!
Metadata
Metadata
Assignees
Labels
No labels