Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6: Added a basic structure of the project #7

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
dist
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2023 Max Krueger, Roman Hlushko

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
VERSION_PACKAGE := glide/pkg
COMMIT ?= $(shell git describe --dirty --long --always --abbrev=15)
VERSION ?= "latest" # TODO: pull/pass a real version

LDFLAGS_COMMON := "-s -w -X $(VERSION_PACKAGE).commitSha=$(COMMIT) -X $(VERSION_PACKAGE).version=$(VERSION)"

.PHONY: help

help:
@echo "🛠️ Glide Dev Commands:\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

lint: ## Lint the source code
@echo "🧹 Vetting go.mod.."
@go vet ./...
@echo "🧹 Cleaning go.mod.."
@go mod tidy
@echo "🧹 GoCI Lint.."
@golangci-lint run ./...

run: ## Run Glide
@go run -ldflags $(LDFLAGS_COMMON) main.go

build: ## Build Glide
@go build -ldflags $(LDFLAGS_COMMON) -o ./dist/glide
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module glide

go 1.21.5
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"glide/pkg"
)

func main() {
println(pkg.GetVersion())
}
18 changes: 18 additions & 0 deletions pkg/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pkg

import (
"fmt"
"runtime"
)

// version must be set from the contents of VERSION file by go build's
// -X main.version= option in the Makefile.
var version = "devel"

// commitSha will be the hash that the binary was built from
// and will be populated by the Makefile
var commitSha = "unknown"

func GetVersion() string {
return fmt.Sprintf("%s (commit: %s, %s)", version, commitSha, runtime.Version())
}