A vanity urls/domain for golang packages.
Go to file
iratusmachina f7ff8eb6b7 WIP 2024-06-30 13:18:26 -04:00
templates Adding other files 2024-05-06 03:20:30 -04:00
testData WIP 2024-06-24 01:55:08 -04:00
.gitignore Adding log_rotation 2024-06-23 09:43:33 -04:00
Makefile WIP 2024-06-23 12:33:34 -04:00
README.md Adding log rotation 2024-06-19 16:16:13 -04:00
app.go Adding log rotation 2024-06-19 16:16:13 -04:00
bytesize.go WIP 2024-06-30 13:18:26 -04:00
bytesize_test.go WIP 2024-06-30 13:18:26 -04:00
conf.go WIP 2024-06-23 12:33:34 -04:00
conf_test.go WIP 2024-06-24 01:55:08 -04:00
embed.go Adding .gitignore and templates folder 2024-05-28 19:30:59 -04:00
go.mod Adding log_rotation 2024-06-23 09:43:33 -04:00
go.sum Adding log_rotation 2024-06-23 09:43:33 -04:00
handlers.go Adding .gitignore and templates folder 2024-05-28 19:30:59 -04:00
logger.go WIP 2024-06-30 13:18:26 -04:00
logger_test.go WIP 2024-06-30 13:18:26 -04:00
main.go WIP 2024-06-23 12:33:34 -04:00
middleware.go Adding other files 2024-05-06 03:20:30 -04:00
testUtils_test.go WIP 2024-06-30 13:18:26 -04:00

README.md

GocustomUrls

This is a homespun implementation of the practice of using custom import paths for go modules.

This package basically returns a html document with a prefilled meta tag

<meta name="go-import" content="{package} git {url location of the package}">

There are ways to do this with nginx or hugo but I wanted to:

  • host on a subdomain
  • not muck up my ngnix config

So I used golang for this project.

Testing

You can test with

(a) httpie

$ http --body "https://{domain.name}/{package}?go-get=1"
...truncated output

(b) With the go-get command

$ go get -v -u jbowen.dev/cereal
get "jbowen.dev/cereal": found meta tag get.metaImport{Prefix:"jbowen.dev/cereal", VCS:"git", RepoRoot:"https://github.com/jamesbo13/cereal"} at //jbowen.dev/cereal?go-get=1
jbowen.dev/cereal (download)

Sample logrotate config

Initial

~/.gocustomurls/logs/app.log {
        size 20M    
        copytruncate
        compress  
        notifempty   
        delaycompress
}

To fix this error

rotating pattern: /home/bloguser/.gocustomurls/logs/app.log  forced from command line (no old logs will be kept)
empty log files are not rotated, old logs are removed
considering log /home/bloguser/.gocustomurls/logs/app.log
error: skipping "/home/bloguser/.gocustomurls/logs/app.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

do this instead

~/.gocustomurls/logs/app.log {
        su bloguser bloguser
        size 20M    
        copytruncate
        compress  
        notifempty   
        delaycompress
}

TODOs

  • Fix permission errors around opening the app.log and rules.json.
  • Make the flags (config, rules) required instead of optional. * Figure how to use logrotate (a linux utility)
  • Figure how to do log rotation as part of this app's function