Skip to content

Commit

Permalink
Simplify module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Sep 3, 2022
1 parent 5f5caae commit 658584c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ signs:
- artifacts: checksum

builds:
- main: cmd/main.go
- main: cmd/gomodule/main.go
env:
- CGO_ENABLED=0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ and summarized under [Releases].
Simply import this module into your project

```go
import "github.com/makenew/gomodule/pkg"
import "github.com/makenew/gomodule"
```

Then run
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go → cmd/gomodule/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/makenew/gomodule/pkg"
"github.com/makenew/gomodule"
)

func main() {
Expand Down
11 changes: 11 additions & 0 deletions gomodule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gomodule

import (
"fmt"

"github.com/makenew/gomodule/internal/todo"
)

func PrintMessage() {
fmt.Println(todo.GetMessage())
}
3 changes: 0 additions & 3 deletions internal/todo.go

This file was deleted.

7 changes: 7 additions & 0 deletions internal/todo/todo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package todo

const message = "TODO"

func GetMessage() string {
return message
}
2 changes: 1 addition & 1 deletion pkg/todo_test.go → internal/todo/todo_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gomodule
package todo

import (
"testing"
Expand Down
9 changes: 7 additions & 2 deletions makenew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ makenew () {
echo 'Example values are shown in parentheses.'
read -p '> Module title (My Module): ' mk_title
read -p '> GitHub user or organization name (my-user): ' mk_user
read -p '> Module and repo name (my-module): ' mk_repo
read -p '> Repo name (my-module): ' mk_repo
read -p '> Module name (mymodule): ' mk_module
read -p '> Short module description (Foos and bars.): ' mk_description
read -p '> Author name (Linus Torvalds): ' mk_author

sed_delete README.md '9,84d'
sed_insert README.md '9i' 'TODO'

git mv gomodule.go "${mk_module}.go"
git mv cmd/gomodule "cmd/${mk_module}"

find_replace "s/Go Module Project Skeleton/${mk_title}/g"
find_replace "s/Project skeleton for a Go module\./${mk_description}/g"
find_replace "s/Evan Sosenko/${mk_author}/g"
find_replace "s|makenew/gomodule|${mk_user}/${mk_repo}|g"
find_replace "s|gomodule|${mk_repo}|g"
find_replace "s|cd gomodule|cd ${mk_repo}|g"
find_replace "s|gomodule|${mk_module}|g"

echo
echo 'Replacing boilerplate.'
Expand Down
14 changes: 0 additions & 14 deletions pkg/todo.go

This file was deleted.

0 comments on commit 658584c

Please sign in to comment.