From 6fe464d55888f1b16a3d38bf21dd8f03d17a4a44 Mon Sep 17 00:00:00 2001 From: Andy Fingerhut Date: Tue, 16 Jul 2024 16:25:33 -0400 Subject: [PATCH] Add brief notes on Golang module creation --- golang/creating-new-golang-module.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 golang/creating-new-golang-module.md diff --git a/golang/creating-new-golang-module.md b/golang/creating-new-golang-module.md new file mode 100644 index 0000000..3b17e5d --- /dev/null +++ b/golang/creating-new-golang-module.md @@ -0,0 +1,22 @@ +I was using go version 1.22.4 while writing these notes. I do not +know whether recommendations have changed across go versions. + +It seems to be recommended to have one module per revision-controlled +repository, e.g. per Github repository. + +There should be a single `go.mod` and `go.sum` file in the root +directory of the repository. + +Such a repository can have many separate programs, each with their own +main package, preferably in different directories of the repo. + +To create the initial `go.mod` file for the repository, after Go is +installed on the system so you can run `go` commands, change to the +root directory of the repository and run this command: + +```bash +go mod init wwwin-github.cisco.com/jafinger/misc +``` + +Replace the URL with the URL of your repository. Omit any `https://` +or `http://` prefix, and any `.git` suffix.