Skip to content

Commit

Permalink
Revert "Increase package version to v2"
Browse files Browse the repository at this point in the history
This reverts commit eae74b2.
  • Loading branch information
aosoriodw committed Jan 16, 2024
1 parent 3a1fa12 commit 4a11747
Show file tree
Hide file tree
Showing 51 changed files with 259 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/datawire/dlib/v2
local-prefixes: github.com/datawire/dlib
errcheck:
exclude: "./.circleci/errcheck-exclude.txt"
nolintlint:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GOVERSION ?= 1.21.6
-e '/MODIFIED: META:/d' \
-e '/MODIFIED: ADDED/d' \
-e 's,.*// MODIFIED: FROM:,,' | \
.circleci/goimports -local github.com/datawire/dlib/v2 \
.circleci/goimports -local github.com/datawire/dlib \
>$@
borrowed.patch: FORCE
$(MAKE) $(addsuffix .unmod,$(shell git ls-files ':*borrowed_*'))
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dlib - Small independent-but-complementary Context-oriented Go libraries

[![PkgGoDev](https://pkg.go.dev/badge/github.com/datawire/dlib/v2)](https://pkg.go.dev/github.com/datawire/dlib/v2)
[![Go Report Card](https://goreportcard.com/badge/github.com/datawire/dlib/v2)](https://goreportcard.com/report/github.com/datawire/dlib/v2)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/datawire/dlib)](https://pkg.go.dev/github.com/datawire/dlib)
[![Go Report Card](https://goreportcard.com/badge/github.com/datawire/dlib)](https://goreportcard.com/report/github.com/datawire/dlib)
[![CircleCI](https://circleci.com/gh/datawire/dlib.svg)](https://circleci.com/gh/datawire/dlib)
[![Coverage Status](https://coveralls.io/repos/github/datawire/dlib/badge.svg)](https://coveralls.io/github/datawire/dlib)

Expand Down Expand Up @@ -46,7 +46,7 @@ to it, and states one of the design principles:
The API of `dexec` is minimal; it's just that of stdlib
`os/exec` that people already know (with one function removed,
at that). The size of the interface is mostly just typing
`github.com/datawire/dlib/v2/dexec` instead of `os/exec`.
`github.com/datawire/dlib/dexec` instead of `os/exec`.

Explicitly not part of the way we use "small" is "small in
implementation". Despite the small API of `dexec`, it has by
Expand Down Expand Up @@ -181,4 +181,4 @@ about having to adjust their program to that package's opinions

Everything is complementary, and so if you drink the Kool-Aid and want
to see how to use everything together, check out [the example in
`example_test.go`](https://pkg.go.dev/github.com/datawire/dlib/v2)
`example_test.go`](https://pkg.go.dev/github.com/datawire/dlib)
2 changes: 1 addition & 1 deletion dcontext/callee_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package dcontext_test
import (
"context"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/dcontext"
)

// This example shows a simple 'exampleCallee' that is a worker function that
Expand Down
2 changes: 1 addition & 1 deletion dcontext/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/dcontext"
)

func TestDebug(t *testing.T) {
Expand Down
31 changes: 17 additions & 14 deletions dcontext/hardsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
//
// Given
//
// softCtx := WithSoftness(hardCtx)
// softCtx := WithSoftness(hardCtx)
//
// then
//
// // The soft Context being done signals the end of "normal
// // operation", and the program should initiate a graceful
// // shutdown; a "soft shutdown". In other words, it means, "You
// // should start shutting down now."
// <-softCtx.Done()
// // The soft Context being done signals the end of "normal
// // operation", and the program should initiate a graceful
// // shutdown; a "soft shutdown". In other words, it means, "You
// // should start shutting down now."
// <-softCtx.Done()
//
// // The hard Context being done signals that the time for a
// // graceful shutdown has passed and that the program should
// // terminate *right now*, not-so-gracefully; a "hard shutdown".
// // In other words, it means, "If you haven't finished shutting
// // down yet, then you should hurry it up."
// <-HardContext(softCtx).Done()
// // The hard Context being done signals that the time for a
// // graceful shutdown has passed and that the program should
// // terminate *right now*, not-so-gracefully; a "hard shutdown".
// // In other words, it means, "If you haven't finished shutting
// // down yet, then you should hurry it up."
// <-HardContext(softCtx).Done()
//
// When writing code that makes use of a Context, which Context should you use,
// the soft Context or the hard Context?
Expand All @@ -33,7 +33,8 @@
// post-shutdown-initiated grace-period, it may be appropriate to use the hard
// Context.
//
// # Design principles
//
// Design principles
//
// - The lifetimes of the various stages (normal operation, shutdown) should be
// signaled with Contexts, rather than with bare channels. Because each stage
Expand Down Expand Up @@ -71,7 +72,9 @@
// drain). Simple code with simple roughly instantaneous shutdown logic need
// not be concerned about hard Contexts and shutdown getting cut short.
//
// # Interfacing dcontext-aware code with dcontext-unaware code
//
//
// Interfacing dcontext-aware code with dcontext-unaware code
//
// When dcontext-aware code passes the soft Context to dcontext-unaware code,
// then that callee code will shutdown at the beginning of the shutdown grace
Expand Down
4 changes: 2 additions & 2 deletions dcontext/hardsoft_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"time"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/v2/dhttp"
"github.com/datawire/dlib/dcontext"
"github.com/datawire/dlib/dhttp"
)

// This should be a very simple example of a parent caller function, showing how
Expand Down
2 changes: 1 addition & 1 deletion dcontext/polling_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package dcontext_test
import (
"context"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/dcontext"
)

// This example shows a simple 'examplePollingCallee' that is a worker function that
Expand Down
15 changes: 7 additions & 8 deletions derrgroup/errgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
// top of errgroup without duplicating and doubling up on all of
// errgroup's synchronization/locking. Anything that can reasonably
// be implemented *on top of* derrgroup is not included in derrgroup:
// - Managing `context.Contexts`s (this is something that errgroup
// kind of does, but derrgroup ripped out, because it can trivially
// be implemented on top of derrgroup)
// - Signal handling
// - Logging
// - Hard/soft cancellation
// - Having `Wait()` timeout on a shutdown that takes too long
//
// - Managing `context.Contexts`s (this is something that errgroup
// kind of does, but derrgroup ripped out, because it can trivially
// be implemented on top of derrgroup)
// - Signal handling
// - Logging
// - Hard/soft cancellation
// - Having `Wait()` timeout on a shutdown that takes too long
// Those are all good and useful things to have. But they should be
// implemented in a layer *on top of* derrgroup. "derrgroup.Group" was
// originally called "llGroup" for "low-level group"; it is
Expand Down
2 changes: 1 addition & 1 deletion derrgroup/errgroup_example_md5all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os"
"path/filepath"

errgroup "github.com/datawire/dlib/v2/derrgroup"
errgroup "github.com/datawire/dlib/derrgroup"
)

// Pipeline demonstrates the use of a Group to implement a multi-stage
Expand Down
2 changes: 1 addition & 1 deletion derrgroup/errgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"os"
"testing"

errgroup "github.com/datawire/dlib/v2/derrgroup"
errgroup "github.com/datawire/dlib/derrgroup"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion derrgroup/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/datawire/dlib/v2/derrgroup"
"github.com/datawire/dlib/derrgroup"
)

func TestNameCollision(t *testing.T) {
Expand Down
28 changes: 14 additions & 14 deletions derror/multierror.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ import (
// Yes, another one. What's wrong with all of the existing ones? Looking at the ones that Emissary
// already imports:
//
// - `github.com/asaskevich/govalidator.Errors` : (1) Doesn't implement .Is(). (2) Output is all
// on one line and hard to read.
// - `github.com/asaskevich/govalidator.Errors` : (1) Doesn't implement .Is(). (2) Output is all
// on one line and hard to read.
//
// - `github.com/getkin/kin-openapi/openapi3.MultiError` : Output is all on one line and hard to
// read.
// - `github.com/getkin/kin-openapi/openapi3.MultiError` : Output is all on one line and hard to
// read.
//
// - `github.com/prometheus/client_golang/prometheus.MultiError` : (1) Doesn't implement .Is().
// (2) Output is pretty good, but doesn't handle child errors having newlines in them.
// - `github.com/prometheus/client_golang/prometheus.MultiError` : (1) Doesn't implement .Is().
// (2) Output is pretty good, but doesn't handle child errors having newlines in them.
//
// - `google.golang.org/appengine.MultiError` : (1) Doesn't implement .Is(). (2) Output is
// "helpfully" summarized to only print the first error and then say "(and X other errors)".
// - `google.golang.org/appengine.MultiError` : (1) Doesn't implement .Is(). (2) Output is
// "helpfully" summarized to only print the first error and then say "(and X other errors)".
//
// - `k8s.io/apimachinery/pkg/util/errors.Aggregate` : (1) Output is all on one line and hard to
// read. (2) Isn't a simple []error type, and so is clunky to work with.
// - `k8s.io/apimachinery/pkg/util/errors.Aggregate` : (1) Output is all on one line and hard to
// read. (2) Isn't a simple []error type, and so is clunky to work with.
//
// - `sigs.k8s.io/controller-tools/pkg/loader.ErrList` : (1) Doesn't implement .Is(). (2) Output
// is all on one line and hard to read.
// - `sigs.k8s.io/controller-tools/pkg/loader.ErrList` : (1) Doesn't implement .Is(). (2) Output
// is all on one line and hard to read.
//
// Note that (like k8s.io/apimachinery/pkg/util/errors.Aggregate) we don't implement .As(), because
// we buy in to the same justification:
//
// // Errors.As() is not supported, because the caller presumably cares about a
// // specific error of potentially multiple that match the given type.
// // Errors.As() is not supported, because the caller presumably cares about a
// // specific error of potentially multiple that match the given type.
type MultiError []error

func (errs MultiError) Error() string {
Expand Down
2 changes: 1 addition & 1 deletion derror/multierror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/datawire/dlib/v2/derror"
"github.com/datawire/dlib/derror"
)

func TestMultiError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion derror/panic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

pkgerrors "github.com/pkg/errors"

"github.com/datawire/dlib/v2/derror"
"github.com/datawire/dlib/derror"
)

var thispackage, thisfile = func() (string, string) {
Expand Down
2 changes: 1 addition & 1 deletion dexec/borrowed_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package dexec // MODIFIED: FROM: package exec
import (
"testing"

"github.com/datawire/dlib/v2/dlog" // MODIFIED: ADDED
"github.com/datawire/dlib/dlog" // MODIFIED: ADDED
)

func BenchmarkExecHostname(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion dexec/borrowed_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"encoding/json"
"fmt"
exec "github.com/datawire/dlib/v2/dexec" // MODIFIED: FROM: "os/exec"
exec "github.com/datawire/dlib/dexec" // MODIFIED: FROM: "os/exec"
"io"
"io/ioutil"
"log"
Expand Down
1 change: 0 additions & 1 deletion dexec/borrowed_exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux && cgo
// +build linux,cgo

// On systems that use glibc, calling malloc can create a new arena,
Expand Down
1 change: 0 additions & 1 deletion dexec/borrowed_exec_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris

package dexec_test // MODIFIED: FROM: package exec_test
Expand Down
8 changes: 4 additions & 4 deletions dexec/borrowed_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
"bytes"
"context"
"fmt"
exec "github.com/datawire/dlib/dexec" // MODIFIED: FROM: "os/exec"
"github.com/datawire/dlib/dexec/internal/poll" // MODIFIED: FROM: "internal/poll"
"github.com/datawire/dlib/dexec/internal/testenv" // MODIFIED: FROM: "internal/testenv"
"io"
"io/ioutil"
"log"
Expand All @@ -29,10 +32,7 @@ import (
"testing"
"time"

exec "github.com/datawire/dlib/v2/dexec" // MODIFIED: FROM: "os/exec"
"github.com/datawire/dlib/v2/dexec/internal/poll" // MODIFIED: FROM: "internal/poll"
"github.com/datawire/dlib/v2/dexec/internal/testenv" // MODIFIED: FROM: "internal/testenv"
"github.com/datawire/dlib/v2/dlog" // MODIFIED: ADDED
"github.com/datawire/dlib/dlog" // MODIFIED: ADDED
)

// haveUnexpectedFDs is set at init time to report whether any
Expand Down
3 changes: 1 addition & 2 deletions dexec/borrowed_read3.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

// This is a test program that verifies that it can read from
Expand All @@ -18,7 +17,7 @@ package main

import (
"fmt"
"github.com/datawire/dlib/v2/dexec/internal/poll" // MODIFIED: FROM: "internal/poll"
"github.com/datawire/dlib/dexec/internal/poll" // MODIFIED: FROM: "internal/poll"
"io/ioutil"
"os"
"os/exec"
Expand Down
10 changes: 5 additions & 5 deletions dexec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
// The logger used is configured in the context.Context passed to
// CommandContext by calling
// github.com/datawire/dlib/v2/dlog.WithLogger.
// github.com/datawire/dlib/dlog.WithLogger.
//
// A Cmd logs when it starts, its exit status, and everything read
// from or written to .Stdin, .Stdout, and .Stderr if they aren't an
Expand Down Expand Up @@ -53,9 +53,9 @@ import (
// we'll use it are situations where stacktraces will be useful.
"github.com/pkg/errors"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/v2/dlog"
"github.com/datawire/dlib/v2/internal/sigint"
"github.com/datawire/dlib/dcontext"
"github.com/datawire/dlib/dlog"
"github.com/datawire/dlib/internal/sigint"
)

// Error is returned by LookPath when it fails to classify a file as an
Expand Down Expand Up @@ -104,7 +104,7 @@ type Cmd struct {
//
// 1. To kill the process (by calling os.Process.Kill) if the context
// becomes done before the command completes on its own.
// 2. For logging (see github.com/datawire/dlib/v2/dlog).
// 2. For logging (see github.com/datawire/dlib/dlog).
//
// See the os/exec.Command and os/exec.CommandContext documentation
// for more information.
Expand Down
1 change: 0 additions & 1 deletion dexec/cmd_posix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build !windows
// +build !windows

package dexec
Expand Down
4 changes: 2 additions & 2 deletions dexec/hardsoft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/stretchr/testify/assert"

"github.com/datawire/dlib/v2/dcontext"
"github.com/datawire/dlib/v2/dexec"
"github.com/datawire/dlib/dcontext"
"github.com/datawire/dlib/dexec"
)

type lineBuffer struct {
Expand Down
8 changes: 4 additions & 4 deletions dexec/internal/testenv/borrowed_testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ package testenv

import (
"errors"
exec "github.com/datawire/dlib/v2/dexec" // MODIFIED: FROM: "os/exec"
"github.com/datawire/dlib/v2/dexec/internal/cfg" // MODIFIED: FROM: "internal/cfg"
exec "github.com/datawire/dlib/dexec" // MODIFIED: FROM: "os/exec"
"github.com/datawire/dlib/dexec/internal/cfg" // MODIFIED: FROM: "internal/cfg"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
)

// HasGoBuild reports whether the current system can build programs with go build
// HasGoBuild reports whether the current system can build programs with ``go build''
// and then run them with os.StartProcess or exec.Command.
func HasGoBuild() bool {
if os.Getenv("GO_GCFLAGS") != "" {
Expand All @@ -45,7 +45,7 @@ func HasGoBuild() bool {
return true
}

// MustHaveGoBuild checks that the current system can build programs with go build
// MustHaveGoBuild checks that the current system can build programs with ``go build''
// and then run them with os.StartProcess or exec.Command.
// If not, MustHaveGoBuild calls t.Skip with an explanation.
func MustHaveGoBuild(t testing.TB) {
Expand Down
Loading

0 comments on commit 4a11747

Please sign in to comment.