Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically place go version in README #21

Open
MSevey opened this issue Nov 14, 2024 · 0 comments
Open

Dynamically place go version in README #21

MSevey opened this issue Nov 14, 2024 · 0 comments
Assignees

Comments

@MSevey
Copy link
Contributor

MSevey commented Nov 14, 2024

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.md

This script:

  • Reads the Go version from go.mod.
  • Updates README.md by 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!

@MSevey MSevey self-assigned this Nov 14, 2024
@MSevey MSevey added this to Rollkit Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant