Skip to content

Commit

Permalink
Fix import prefix trailing slash (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Aug 8, 2024
1 parent a443bc5 commit 298ab36
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
9 changes: 8 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ type repository struct {
Website website `json:"website"`
}

func (r repository) PrefixPath() string {
if r.Prefix == "" {
return ""
} else {
return "/" + r.Prefix
}
}

func (r repository) Packages() []string {
pkgs := []string{r.Prefix}
for i := range r.Subs {
Expand Down Expand Up @@ -75,7 +83,6 @@ type website struct {

func parseConfig(r io.Reader) (config, error) {
bytes, err := ioutil.ReadAll(r)

if err != nil {
return config{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions generate_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func generate_package(w io.Writer, domain, docsDomain, pkg string, r repository)
<head>
<meta charset="utf-8">
<title>{{.Domain}}/{{.Package}}</title>
<meta name="go-import" content="{{.Domain}}/{{.Repository.Prefix}} {{.Repository.Type}} {{.Repository.URL}}">
<meta name="go-source" content="{{.Domain}}/{{.Repository.Prefix}} {{.Repository.SourceURLs.Home}} {{.Repository.SourceURLs.Dir}} {{.Repository.SourceURLs.File}}">
<meta name="go-import" content="{{.Domain}}{{.Repository.PrefixPath}} {{.Repository.Type}} {{.Repository.URL}}">
<meta name="go-source" content="{{.Domain}}{{.Repository.PrefixPath}} {{.Repository.SourceURLs.Home}} {{.Repository.SourceURLs.Dir}} {{.Repository.SourceURLs.File}}">
<style>
* { font-family: sans-serif; }
body { margin-top: 0; }
Expand Down
4 changes: 2 additions & 2 deletions generate_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ Sub-packages:<ul><li><a href="/pkg1/subpkg1">example.com/pkg1/subpkg1</a></li><l
<head>
<meta charset="utf-8">
<title>example.com/</title>
<meta name="go-import" content="example.com/ git https://github.com/example/go-pkg1">
<meta name="go-source" content="example.com/ https://github.com/example/go-pkg1 https://github.com/example/go-pkg1/tree/branch{/dir} https://github.com/example/go-pkg1/blob/branch{/dir}/{file}#L{line}">
<meta name="go-import" content="example.com git https://github.com/example/go-pkg1">
<meta name="go-source" content="example.com https://github.com/example/go-pkg1 https://github.com/example/go-pkg1/tree/branch{/dir} https://github.com/example/go-pkg1/blob/branch{/dir}/{file}#L{line}">
<style>
* { font-family: sans-serif; }
body { margin-top: 0; }
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module 4d63.com/vangen

go 1.21.0

require github.com/sergi/go-diff v1.0.0

require (
github.com/sergi/go-diff v1.0.0
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.1.0 // indirect
github.com/stretchr/testify v1.3.0 // indirect
)

0 comments on commit 298ab36

Please sign in to comment.