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

Use embed.FS for templates #5303

Merged
merged 2 commits into from
May 9, 2024
Merged

Use embed.FS for templates #5303

merged 2 commits into from
May 9, 2024

Conversation

utgwkk
Copy link
Contributor

@utgwkk utgwkk commented May 7, 2024

There is a TODO comment in main.go.

awesome-go/main.go

Lines 45 to 49 in 18c06bc

// TODO: embed
// Templates
var tplIndex = template.Must(template.ParseFiles("tmpl/index.tmpl.html"))
var tplCategoryIndex = template.Must(template.ParseFiles("tmpl/category-index.tmpl.html"))
var tplSitemap = template.Must(template.ParseFiles("tmpl/sitemap.tmpl.xml"))

So I implemented it by using go:embed directive and embed.FS

Copy link

github-actions bot commented May 7, 2024

Thank you for contributing to awesome-go. We will review your contribution as soon as possible.

Make sure you add the links in the body of the pull request that are requested in the contribution guide:

  • repo link
  • pkg.go.dev
  • goreportcard.com
  • coverage

Your project is under review. It may take a few days to be approved.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @utgwkk - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

main.go Outdated Show resolved Hide resolved
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@ccoVeille
Copy link

Interesting idea you got, I never looked at embed.FS thanks for sharing

@phanirithvij phanirithvij merged commit 8d3e047 into avelino:main May 9, 2024
3 checks passed
@utgwkk utgwkk deleted the embed branch May 9, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants