chore: Add nix shell for simple development setup (#3399)

* chore: Add nix shell for simple development setup

This enables contributors using Nix to set up their environment with ease.

* improve nix style, flake output schema

* fix error message

* Update scripts/build_go_slim.sh

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update scripts/build_go_slim.sh

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Add UTC default for timezone and remove unnecessary goreleaser dependency

* Skip TZ test if localtime does not exist

Co-authored-by: Charlie Moog <moogcharlie@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
Kyle Carberry
2022-08-08 10:49:12 -05:00
committed by GitHub
parent 3279504cbe
commit 9c12b4ed8e
9 changed files with 175 additions and 9 deletions

View File

@ -33,7 +33,6 @@ func TimezoneIANA() (*time.Location, error) {
if err != nil {
return nil, xerrors.Errorf("read location of %s: %w", etcLocaltime, err)
}
stripped := strings.Replace(lp, zoneInfoPath, "", -1)
stripped = strings.TrimPrefix(stripped, string(filepath.Separator))
loc, err = time.LoadLocation(stripped)

View File

@ -2,6 +2,7 @@ package tz_test
import (
"os"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
@ -25,6 +26,11 @@ func Test_TimezoneIANA(t *testing.T) {
//nolint:paralleltest // UnsetEnv
t.Run("NoEnv", func(t *testing.T) {
_, err := os.Stat("/etc/localtime")
if runtime.GOOS == "linux" && err != nil {
// Not all Linux operating systems are guaranteed to have localtime!
t.Skip("localtime doesn't exist!")
}
oldEnv, found := os.LookupEnv("TZ")
if found {
require.NoError(t, os.Unsetenv("TZ"))