|
| 1 | +# Proposal: make the internal [lockedfile](https://godoc.org/github.com/golang/go/src/cmd/go/internal/lockedfile/) package public |
| 2 | + |
| 3 | +Author(s): [Adrien Delorme] |
| 4 | + |
| 5 | +Last updated: 2019-10-15 |
| 6 | + |
| 7 | +Discussion at https://golang.org/issue/33974. |
| 8 | + |
| 9 | +## Abstract |
| 10 | + |
| 11 | +Move already existing code residing golang/go/src/cmd/go/internal/lockedfile to |
| 12 | +`x/exp`. At `x/exp/lockedfile`. |
| 13 | + |
| 14 | +## Background |
| 15 | + |
| 16 | +A few Golang open source projects are implementing file locking mechanisms |
| 17 | +( https://github.com/gofrs/flock, https://github.com/MichaelS11/go-file-lock, |
| 18 | +https://github.com/juju/fslock ) but they do not seem to be maintained anymore, |
| 19 | +issues are ignored and they seem untrusted. |
| 20 | +As a result some major projects are doing their own version of it; ex: |
| 21 | +[terraform](https://github.com/hashicorp/terraform/blob/1ff9a540202b8c36e33db950374bbb4495737d8f/states/statemgr/filesystem_lock_unix.go), |
| 22 | +[boltdb](https://github.com/boltdb/bolt/search?q=flock&unscoped_q=flock). |
| 23 | +After some researches it seemed to us that the already existing and maintained |
| 24 | +[lockedfile](https://godoc.org/github.com/golang/go/src/cmd/go/internal/lockedfile/) |
| 25 | +package is the best 'open source' version. |
| 26 | + |
| 27 | +File locking seems complicated and low level enough to be more closely |
| 28 | +maintained by the go community ( and/or team ? ). |
| 29 | +We think it would benefit the mass to make such a package public: since it's |
| 30 | +already being part of the go code and therefore being maintained; it should be |
| 31 | +made public. |
| 32 | + |
| 33 | +## Proposal |
| 34 | + |
| 35 | +We propose to copy the golang/go/src/cmd/go/internal/lockedfile to `x/exp`. To |
| 36 | +make it public. Not changing any of the named types for now. |
| 37 | + |
| 38 | +## Rationale |
| 39 | + |
| 40 | +The golang/go/src/cmd/go/internal/lockedfile already exists but has untrusted & |
| 41 | +unmaintained alternatives. |
| 42 | + |
| 43 | +* Making this package public will make it more used. A tiny surge of issues |
| 44 | + might come in the beginning; at the benefits of everyone. ( Unless it's |
| 45 | + bug free !! ). |
| 46 | + |
| 47 | +* There exists a https://godoc.org/github.com/rogpeppe/go-internal package that |
| 48 | + exports a lot of internal packages from the go repo. But if go-internal |
| 49 | + became wildly popular; in order to have a bug fixed or a feature introduced |
| 50 | + in; a user would still need to open a PR on the go repo; then the author of |
| 51 | + go-internal would need to update the package. |
| 52 | + |
| 53 | +## Compatibility |
| 54 | + |
| 55 | +There are no compatibility issues. Since this will be a code addition. |
| 56 | + |
| 57 | +## Implementation |
| 58 | + |
| 59 | +Adrien Delorme plans to do copy the internal/lockedfile package from cmd/go to |
| 60 | +`x/exp`. |
0 commit comments