Restructuring: main package in project root
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 159f30b · Browse files · 8 files·+151 added−250 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+151 added−250 removed
- other:+151 added−250 removed
Provenance
- Commit
8bbf933- Tree
23fd133- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
159f30b
8 files changed+151 added−250 removed
deleted:src/fzf/main.go-7 removed
1-package main2-3-import "github.com/junegunn/fzf/src"4-5-func main() {6- fzf.Run(fzf.ParseOptions())7-}deleted:src/Makefile-119 removed
1-ifndef GOOS2-UNAME_S := $(shell uname -s)3-ifeq ($(UNAME_S),Darwin)4- GOOS := darwin5-else ifeq ($(UNAME_S),Linux)6- GOOS := linux7-else8-$(error "$$GOOS is not defined.")9-endif10-endif11-12-SOURCES := $(wildcard *.go */*.go)13-ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))14-BINDIR := $(shell dirname $(ROOTDIR))/bin15-BINARY32 := fzf-$(GOOS)_38616-BINARY64 := fzf-$(GOOS)_amd6417-BINARYARM5 := fzf-$(GOOS)_arm518-BINARYARM6 := fzf-$(GOOS)_arm619-BINARYARM7 := fzf-$(GOOS)_arm720-BINARYARM8 := fzf-$(GOOS)_arm821-VERSION := $(shell awk -F= '/version =/ {print $$2}' constants.go | tr -d "\" ")22-RELEASE32 := fzf-$(VERSION)-$(GOOS)_38623-RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd6424-RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm525-RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm626-RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm727-RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm828-29-# https://en.wikipedia.org/wiki/Uname30-UNAME_M := $(shell uname -m)31-ifeq ($(UNAME_M),x86_64)32- BINARY := $(BINARY64)33-else ifeq ($(UNAME_M),amd64)34- BINARY := $(BINARY64)35-else ifeq ($(UNAME_M),i686)36- BINARY := $(BINARY32)37-else ifeq ($(UNAME_M),i386)38- BINARY := $(BINARY32)39-else ifeq ($(UNAME_M),armv5l)40- BINARY := $(BINARYARM5)41-else ifeq ($(UNAME_M),armv6l)42- BINARY := $(BINARYARM6)43-else ifeq ($(UNAME_M),armv7l)44- BINARY := $(BINARYARM7)45-else46-$(error "Build on $(UNAME_M) is not supported, yet.")47-endif48-49-all: fzf/$(BINARY)50-51-ifeq ($(GOOS),windows)52-release: fzf/$(BINARY32) fzf/$(BINARY64)53- cd fzf && cp -f $(BINARY32) fzf.exe && zip $(RELEASE32).zip fzf.exe54- cd fzf && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe55- cd fzf && rm -f fzf.exe56-else ifeq ($(GOOS),linux)57-release: fzf/$(BINARY32) fzf/$(BINARY64) fzf/$(BINARYARM5) fzf/$(BINARYARM6) fzf/$(BINARYARM7) fzf/$(BINARYARM8)58- cd fzf && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf59- cd fzf && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf60- cd fzf && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf61- cd fzf && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf62- cd fzf && cp -f $(BINARYARM7) fzf && tar -czf $(RELEASEARM7).tgz fzf63- cd fzf && cp -f $(BINARYARM8) fzf && tar -czf $(RELEASEARM8).tgz fzf64- cd fzf && rm -f fzf65-else66-release: fzf/$(BINARY32) fzf/$(BINARY64)67- cd fzf && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf68- cd fzf && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf69- cd fzf && rm -f fzf70-endif71-72-release-all: clean test73- GOOS=darwin make release74- GOOS=linux make release75- GOOS=freebsd make release76- GOOS=openbsd make release77- GOOS=windows make release78-79-deps: $(SOURCES)80- cd .. && go get -u github.com/Masterminds/glide && $(GOPATH)/bin/glide install81-82-test: deps83- SHELL=/bin/sh GOOS= go test -v -tags "$(TAGS)" ./...84-85-install: $(BINDIR)/fzf86-87-uninstall:88- rm -f $(BINDIR)/fzf $(BINDIR)/$(BINARY)89-90-clean:91- cd fzf && rm -f fzf-*92-93-fzf/$(BINARY32): deps94- cd fzf && GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY32)95-96-fzf/$(BINARY64): deps97- cd fzf && GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY64)98-99-# https://github.com/golang/go/wiki/GoArm100-fzf/$(BINARYARM5): deps101- cd fzf && GOARCH=arm GOARM=5 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM5)102-103-fzf/$(BINARYARM6): deps104- cd fzf && GOARCH=arm GOARM=6 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM6)105-106-fzf/$(BINARYARM7): deps107- cd fzf && GOARCH=arm GOARM=7 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM7)108-109-fzf/$(BINARYARM8): deps110- cd fzf && GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM8)111-112-$(BINDIR)/fzf: fzf/$(BINARY) | $(BINDIR)113- cp -f fzf/$(BINARY) $(BINDIR)114- cd $(BINDIR) && ln -sf $(BINARY) fzf115-116-$(BINDIR):117- mkdir -p $@118-119-.PHONY: all deps release release-all test install uninstall cleandeleted:src/README.md-106 removed
1-fzf in Go2-=========3-4-<img src="https://cloud.githubusercontent.com/assets/700826/5725028/028ea834-9b93-11e4-9198-43088c3f295d.gif" height="463" alt="fzf in go">5-6-This directory contains the source code for the new fzf implementation in7-[Go][go].8-9-Upgrade from Ruby version10--------------------------11-12-The install script has been updated to download the right binary for your13-system. If you already have installed fzf, simply git-pull the repository and14-rerun the install script.15-16-```sh17-cd ~/.fzf18-git pull19-./install20-```21-22-Otherwise, follow [the instruction][install] as before. You can also install23-fzf using Homebrew if you prefer that way.24-25-Motivations26------------27-28-### No Ruby dependency29-30-There have always been complaints about fzf being a Ruby script. To make31-matters worse, Ruby 2.1 removed ncurses binding from its standard libary.32-Because of the change, users running Ruby 2.1 or above are forced to build C33-extensions of curses gem to meet the requirement of fzf. The new Go version34-will be distributed as an executable binary so it will be much more accessible35-and should be easier to setup.36-37-### Performance38-39-Many people have been surprised to see how fast fzf is even when it was40-written in Ruby. It stays quite responsive even for 100k+ lines, which is41-well above the size of the usual input.42-43-The new Go version, of course, is significantly faster than that. It has all44-the performance optimization techniques used in Ruby implementation and more.45-It also doesn't suffer from [GIL][gil], so the search performance scales46-proportional to the number of CPU cores. On my MacBook Pro (Mid 2012), the new47-version was shown to be an order of magnitude faster on certain cases. It also48-starts much faster though the difference may not be noticeable.49-50-Build51------52-53-See [BUILD.md](../BUILD.md)54-55-Test56-----57-58-Unit tests can be run with `make test`. Integration tests are written in Ruby59-script that should be run on tmux.60-61-```sh62-cd src63-64-# Unit tests65-make test66-67-# Integration tests68-ruby ../test/test_go.rb69-70-# Build binary for the platform71-make72-73-# Install the executable to ../bin directory74-make install75-76-# Make release archives77-make release78-79-# Make release archives for all supported platforms80-make release-all81-```82-83-Third-party libraries used84---------------------------85-86-- ~[ncurses][ncurses]~87-- [mattn/go-runewidth](https://github.com/mattn/go-runewidth)88- - Licensed under [MIT](http://mattn.mit-license.org)89-- [mattn/go-shellwords](https://github.com/mattn/go-shellwords)90- - Licensed under [MIT](http://mattn.mit-license.org)91-- [mattn/go-isatty](https://github.com/mattn/go-isatty)92- - Licensed under [MIT](http://mattn.mit-license.org)93-- [tcell](https://github.com/gdamore/tcell)94- - Licensed under [Apache License 2.0](https://github.com/gdamore/tcell/blob/master/LICENSE)95-96-License97--------98-99-[MIT](LICENSE)100-101-[install]: https://github.com/junegunn/fzf#installation102-[go]: https://golang.org/103-[gil]: http://en.wikipedia.org/wiki/Global_Interpreter_Lock104-[ncurses]: https://www.gnu.org/software/ncurses/105-[req]: http://golang.org/doc/install106-[tcell]: https://github.com/gdamore/tcellmodified:.gitignore+2 added-2 removed
1-bin2-src/fzf/fzf-*1+bin/fzf2+target3 pkg4 Gemfile.lock5 .DS_Store6 doc/tags1 unmodified linemodified:.travis.yml+2 added-9 removed
14 unmodified lines1516171819202122232425262719202114 unmodified lines- sudo apt-get install -y tmux=1.9a-1~ppa1~p- sudo apt-get install -y zsh fish
script: | export GOPATH=~/go export FZF_BASE=$GOPATH/src/github.com/junegunn/fzf
mkdir -p $GOPATH/src/github.com/junegunn ln -s $(pwd) $FZF_BASE
cd $FZF_BASE/src && make test fzf/fzf-linux_amd64 install && cd $FZF_BASE/bin && ln -sf fzf-linux_amd64 fzf-$(./fzf --version)-linux_amd64 && cd $FZF_BASE && yes | ./install && rm -f fzf && make test install && ./install --all && tmux new "ruby test/test_go.rb > out && touch ok" && cat out && [ -e ok ]modified:BUILD.md+6 added-7 removed
8 unmodified lines91011121314151314151716171819202123222324262526272829303132333436353637383914 unmodified lines8 unmodified lines- `go` executable in $PATH
### Using Makefile
```sh# Source files are located in src directorycd srcMakefile will set up and use its own `$GOPATH` under the project root.
```sh# Build fzf binary for your platform in src/fzf# Build fzf binary for your platform in targetmake
# Build fzf binary and copy it to bin directorymake install
# Build 32-bit and 64-bit executables and tarballs# Build 32-bit and 64-bit executables and tarballs in targetmake release
# Make release archives for all supported platforms# Make release archives for all supported platforms in targetmake release-all```
### Using `go get`
Alternatively, you can build fzf directly with `go get` command withoutmanually cloning the repository.
```shgo get -u github.com/junegunn/fzf/src/fzfgo get -u github.com/junegunn/fzf```
Third-party libraries used--------------------------14 unmodified linesadded:main.go+7 added
1+package main2+3+import "github.com/junegunn/fzf/src"4+5+func main() {6+ fzf.Run(fzf.ParseOptions())7+}added:Makefile+134 added
1+ifndef GOOS2+UNAME_S := $(shell uname -s)3+ifeq ($(UNAME_S),Darwin)4+ GOOS := darwin5+else ifeq ($(UNAME_S),Linux)6+ GOOS := linux7+else8+$(error "$$GOOS is not defined.")9+endif10+endif11+12+ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))13+GOPATH := $(ROOT_DIR)/gopath14+SRC_LINK := $(GOPATH)/src/github.com/junegunn/fzf/src15+VENDOR_LINK := $(GOPATH)/src/github.com/junegunn/fzf/vendor16+17+GLIDE_YAML := glide.yaml18+GLIDE_LOCK := glide.lock19+SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK)20+21+BINARY32 := fzf-$(GOOS)_38622+BINARY64 := fzf-$(GOOS)_amd6423+BINARYARM5 := fzf-$(GOOS)_arm524+BINARYARM6 := fzf-$(GOOS)_arm625+BINARYARM7 := fzf-$(GOOS)_arm726+BINARYARM8 := fzf-$(GOOS)_arm827+VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")28+RELEASE32 := fzf-$(VERSION)-$(GOOS)_38629+RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd6430+RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm531+RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm632+RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm733+RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm834+export GOPATH35+36+# https://en.wikipedia.org/wiki/Uname37+UNAME_M := $(shell uname -m)38+ifeq ($(UNAME_M),x86_64)39+ BINARY := $(BINARY64)40+else ifeq ($(UNAME_M),amd64)41+ BINARY := $(BINARY64)42+else ifeq ($(UNAME_M),i686)43+ BINARY := $(BINARY32)44+else ifeq ($(UNAME_M),i386)45+ BINARY := $(BINARY32)46+else ifeq ($(UNAME_M),armv5l)47+ BINARY := $(BINARYARM5)48+else ifeq ($(UNAME_M),armv6l)49+ BINARY := $(BINARYARM6)50+else ifeq ($(UNAME_M),armv7l)51+ BINARY := $(BINARYARM7)52+else53+$(error "Build on $(UNAME_M) is not supported, yet.")54+endif55+56+all: target/$(BINARY)57+58+target:59+ mkdir -p $@60+61+ifeq ($(GOOS),windows)62+release: target/$(BINARY32) target/$(BINARY64)63+ cd target && cp -f $(BINARY32) fzf.exe && zip $(RELEASE32).zip bin/fzf.exe64+ cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip bin/fzf.exe65+ cd target && rm -f fzf.exe66+else ifeq ($(GOOS),linux)67+release: target/$(BINARY32) target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8)68+ cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf69+ cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf70+ cd target && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf71+ cd target && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf72+ cd target && cp -f $(BINARYARM7) fzf && tar -czf $(RELEASEARM7).tgz fzf73+ cd target && cp -f $(BINARYARM8) fzf && tar -czf $(RELEASEARM8).tgz fzf74+ cd target && rm -f fzf75+else76+release: target/$(BINARY32) target/$(BINARY64)77+ cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf78+ cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf79+ cd target && rm -f fzf80+endif81+82+release-all: clean test83+ GOOS=darwin make release84+ GOOS=linux make release85+ GOOS=freebsd make release86+ GOOS=openbsd make release87+ GOOS=windows make release88+89+$(SRC_LINK):90+ mkdir -p $(shell dirname $(SRC_LINK))91+ ln -s $(ROOT_DIR)/src $(SRC_LINK)92+93+$(VENDOR_LINK):94+ mkdir -p $(shell dirname $(VENDOR_LINK))95+ ln -s $(ROOT_DIR)/vendor $(VENDOR_LINK)96+97+$(GLIDE_LOCK): $(GLIDE_YAML)98+ go get -u github.com/Masterminds/glide && $(GOPATH)/bin/glide install && touch $@99+100+test: $(SOURCES)101+ SHELL=/bin/sh GOOS= go test -v -tags "$(TAGS)" \102+ github.com/junegunn/fzf/src \103+ github.com/junegunn/fzf/src/algo \104+ github.com/junegunn/fzf/src/tui \105+ github.com/junegunn/fzf/src/util106+107+install: bin/fzf108+109+clean:110+ rm -rf target111+112+target/$(BINARY32): $(SOURCES)113+ GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@114+115+target/$(BINARY64): $(SOURCES)116+ GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@117+118+# https://github.com/golang/go/wiki/GoArm119+target/$(BINARYARM5): $(SOURCES)120+ GOARCH=arm GOARM=5 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@121+122+target/$(BINARYARM6): $(SOURCES)123+ GOARCH=arm GOARM=6 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@124+125+target/$(BINARYARM7): $(SOURCES)126+ GOARCH=arm GOARM=7 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@127+128+target/$(BINARYARM8): $(SOURCES)129+ GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@130+131+bin/fzf: target/$(BINARY) | bin132+ cp -f target/$(BINARY) bin/fzf133+134+.PHONY: all release release-all test install clean