Merge branch 'main' into hedzr-patch-1

This commit is contained in:
hz 2024-09-24 07:52:39 +08:00 committed by GitHub
commit 362fd9c471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 282 additions and 165 deletions

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
container: golang:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get dependencies
run: go get -v -t -d ./...
- name: run script

View File

@ -15,7 +15,7 @@ jobs:
environment: netlify
container: golang:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get dependencies
run: go get -v -t -d ./...
- name: Make awesome-go.com

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
container: golang:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get dependencies
run: go get -v -t -d ./...
- name: Run tests

412
README.md

File diff suppressed because it is too large Load Diff

4
go.mod
View File

@ -13,9 +13,9 @@ require (
require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect

8
go.sum
View File

@ -27,8 +27,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ=
golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -42,8 +42,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=

15
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"embed"
"errors"
"fmt"
template2 "html/template"
@ -42,11 +43,11 @@ var staticFiles = []string{
"tmpl/robots.txt",
}
// 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"))
//go:embed tmpl/*.tmpl.html tmpl/*.tmpl.xml
var tplFs embed.FS
var tpl = template.Must(template.ParseFS(tplFs, "tmpl/*.tmpl.html", "tmpl/*.tmpl.xml"))
// Output files
const outDir = "out/" // NOTE: trailing slash is required
@ -152,7 +153,7 @@ func renderCategories(categories map[string]Category) error {
fmt.Printf("Write category Index file: %s\n", categoryIndexFilename)
buf := bytes.NewBuffer(nil)
if err := tplCategoryIndex.Execute(buf, category); err != nil {
if err := tpl.Lookup("category-index.tmpl.html").Execute(buf, category); err != nil {
return fmt.Errorf("render category `%s`: %w", categoryDir, err)
}
@ -186,7 +187,7 @@ func renderSitemap(categories map[string]Category) error {
fmt.Printf("Render Sitemap to: %s\n", outSitemapFile)
if err := tplSitemap.Execute(f, categories); err != nil {
if err := tpl.Lookup("sitemap.tmpl.xml").Execute(f, categories); err != nil {
return fmt.Errorf("render sitemap: %w", err)
}
@ -352,7 +353,7 @@ func renderIndex(srcFilename, outFilename string) error {
data := map[string]interface{}{
"Body": template2.HTML(body),
}
if err := tplIndex.Execute(f, data); err != nil {
if err := tpl.Lookup("index.tmpl.html").Execute(f, data); err != nil {
return err
}

View File

@ -39,7 +39,7 @@ var awesomeGoGETISSUES = "http://api.github.com/repos/avelino/awesome-go/issues"
// time.Hour * ... or change type of variable
var numberOfYears time.Duration = 1
var timeNow = time.Now()
var issueTitle = fmt.Sprintf("Investigate repositories with more than 1 year without update - %s", timeNow.Format("2006-01-02"))
var issueTitle = fmt.Sprintf("Investigate repositories with more than 1 year without update - %s", timeNow.Format(time.DateOnly))
const deadLinkMessage = " this repository might no longer exist! (status code >= 400 returned)"
const movedPermanently = " status code 301 received"