Skip to content

support for generated .go files (e.g. timestamp) #429

@bstarynk

Description

@bstarynk

I am just starting a new Go project (a hobby project, GPLv3+, on gitlab, for some sort of wiki thing). I am using Linux/Debian/Sid with Go 1.11.1 and I don't care about non-Linux systems (so portability to Windows is not a concern).

I really want to have a small .go file generated at every build. That file just defines two strings (one for the build timestamp, one for its git commit).

This StackOverflow question describes what I have in mind. I would like to generate at every build some timestamp.go file having something similar to

// generated timestamp.go file
package timestamp
var Buildtime = "Tue 30 Oct 2018 09:39:01 AM MET";
var Buildlastgitcommit = "7fde394b60bc adding timestamp.go"

The Buildtime string is obtained by date +%c. The Buildlastcommit string is obtained by a few git commands.

Is godel the right tool for this? I cannot easily find in the documentation of godel how generated .go files are managed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions