Skip to content
Myr

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

8 files+151 added−250 removed

deleted:src/fzf/main.go-7 removed
1package main23import "github.com/junegunn/fzf/src"45func main() {6 fzf.Run(fzf.ParseOptions())7}
deleted:src/Makefile-119 removed
1ifndef GOOS2UNAME_S := $(shell uname -s)3ifeq ($(UNAME_S),Darwin)4 GOOS := darwin5else ifeq ($(UNAME_S),Linux)6 GOOS := linux7else8$(error "$$GOOS is not defined.")9endif10endif1112SOURCES := $(wildcard *.go */*.go)13ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))14BINDIR := $(shell dirname $(ROOTDIR))/bin15BINARY32 := fzf-$(GOOS)_38616BINARY64 := fzf-$(GOOS)_amd6417BINARYARM5 := fzf-$(GOOS)_arm518BINARYARM6 := fzf-$(GOOS)_arm619BINARYARM7 := fzf-$(GOOS)_arm720BINARYARM8 := fzf-$(GOOS)_arm821VERSION := $(shell awk -F= '/version =/ {print $$2}' constants.go | tr -d "\" ")22RELEASE32 := fzf-$(VERSION)-$(GOOS)_38623RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd6424RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm525RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm626RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm727RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm82829# https://en.wikipedia.org/wiki/Uname30UNAME_M := $(shell uname -m)31ifeq ($(UNAME_M),x86_64)32 BINARY := $(BINARY64)33else ifeq ($(UNAME_M),amd64)34 BINARY := $(BINARY64)35else ifeq ($(UNAME_M),i686)36 BINARY := $(BINARY32)37else ifeq ($(UNAME_M),i386)38 BINARY := $(BINARY32)39else ifeq ($(UNAME_M),armv5l)40 BINARY := $(BINARYARM5)41else ifeq ($(UNAME_M),armv6l)42 BINARY := $(BINARYARM6)43else ifeq ($(UNAME_M),armv7l)44 BINARY := $(BINARYARM7)45else46$(error "Build on $(UNAME_M) is not supported, yet.")47endif4849all: fzf/$(BINARY)5051ifeq ($(GOOS),windows)52release: 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.exe56else ifeq ($(GOOS),linux)57release: 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 fzf65else66release: 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 fzf70endif7172release-all: clean test73 GOOS=darwin make release74 GOOS=linux make release75 GOOS=freebsd make release76 GOOS=openbsd make release77 GOOS=windows make release7879deps: $(SOURCES)80 cd .. && go get -u github.com/Masterminds/glide && $(GOPATH)/bin/glide install8182test: deps83 SHELL=/bin/sh GOOS= go test -v -tags "$(TAGS)" ./...8485install: $(BINDIR)/fzf8687uninstall:88 rm -f $(BINDIR)/fzf $(BINDIR)/$(BINARY)8990clean:91 cd fzf && rm -f fzf-*9293fzf/$(BINARY32): deps94 cd fzf && GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY32)9596fzf/$(BINARY64): deps97 cd fzf && GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARY64)9899# https://github.com/golang/go/wiki/GoArm100fzf/$(BINARYARM5): deps101 cd fzf && GOARCH=arm GOARM=5 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM5)102103fzf/$(BINARYARM6): deps104 cd fzf && GOARCH=arm GOARM=6 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM6)105106fzf/$(BINARYARM7): deps107 cd fzf && GOARCH=arm GOARM=7 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM7)108109fzf/$(BINARYARM8): deps110 cd fzf && GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $(BINARYARM8)111112$(BINDIR)/fzf: fzf/$(BINARY) | $(BINDIR)113 cp -f fzf/$(BINARY) $(BINDIR)114 cd $(BINDIR) && ln -sf $(BINARY) fzf115116$(BINDIR):117 mkdir -p $@118119.PHONY: all deps release release-all test install uninstall clean
deleted:src/README.md-106 removed
1fzf in Go2=========34<img src="https://cloud.githubusercontent.com/assets/700826/5725028/028ea834-9b93-11e4-9198-43088c3f295d.gif" height="463" alt="fzf in go">56This directory contains the source code for the new fzf implementation in7[Go][go].89Upgrade from Ruby version10-------------------------1112The install script has been updated to download the right binary for your13system. If you already have installed fzf, simply git-pull the repository and14rerun the install script.1516```sh17cd ~/.fzf18git pull19./install20```2122Otherwise, follow [the instruction][install] as before. You can also install23fzf using Homebrew if you prefer that way.2425Motivations26-----------2728### No Ruby dependency2930There have always been complaints about fzf being a Ruby script. To make31matters worse, Ruby 2.1 removed ncurses binding from its standard libary.32Because of the change, users running Ruby 2.1 or above are forced to build C33extensions of curses gem to meet the requirement of fzf. The new Go version34will be distributed as an executable binary so it will be much more accessible35and should be easier to setup.3637### Performance3839Many people have been surprised to see how fast fzf is even when it was40written in Ruby. It stays quite responsive even for 100k+ lines, which is41well above the size of the usual input.4243The new Go version, of course, is significantly faster than that. It has all44the performance optimization techniques used in Ruby implementation and more.45It also doesn't suffer from [GIL][gil], so the search performance scales46proportional to the number of CPU cores. On my MacBook Pro (Mid 2012), the new47version was shown to be an order of magnitude faster on certain cases. It also48starts much faster though the difference may not be noticeable.4950Build51-----5253See [BUILD.md](../BUILD.md)5455Test56----5758Unit tests can be run with `make test`. Integration tests are written in Ruby59script that should be run on tmux.6061```sh62cd src6364# Unit tests65make test6667# Integration tests68ruby ../test/test_go.rb6970# Build binary for the platform71make7273# Install the executable to ../bin directory74make install7576# Make release archives77make release7879# Make release archives for all supported platforms80make release-all81```8283Third-party libraries used84--------------------------8586- ~[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)9596License97-------9899[MIT](LICENSE)100101[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/tcell
modified:.gitignore+2 added-2 removed
1bin2src/fzf/fzf-*1bin/fzf2target3pkg4Gemfile.lock5.DS_Store6doc/tags
1 unmodified line
modified:.travis.yml+2 added-9 removed
modified:BUILD.md+6 added-7 removed
added:main.go+7 added
1package main23import "github.com/junegunn/fzf/src"45func main() {6 fzf.Run(fzf.ParseOptions())7}
added:Makefile+134 added
1ifndef GOOS2UNAME_S := $(shell uname -s)3ifeq ($(UNAME_S),Darwin)4 GOOS := darwin5else ifeq ($(UNAME_S),Linux)6 GOOS := linux7else8$(error "$$GOOS is not defined.")9endif10endif1112ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))13GOPATH := $(ROOT_DIR)/gopath14SRC_LINK := $(GOPATH)/src/github.com/junegunn/fzf/src15VENDOR_LINK := $(GOPATH)/src/github.com/junegunn/fzf/vendor1617GLIDE_YAML := glide.yaml18GLIDE_LOCK := glide.lock19SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK)2021BINARY32 := fzf-$(GOOS)_38622BINARY64 := fzf-$(GOOS)_amd6423BINARYARM5 := fzf-$(GOOS)_arm524BINARYARM6 := fzf-$(GOOS)_arm625BINARYARM7 := fzf-$(GOOS)_arm726BINARYARM8 := fzf-$(GOOS)_arm827VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")28RELEASE32 := fzf-$(VERSION)-$(GOOS)_38629RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd6430RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm531RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm632RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm733RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm834export GOPATH3536# https://en.wikipedia.org/wiki/Uname37UNAME_M := $(shell uname -m)38ifeq ($(UNAME_M),x86_64)39 BINARY := $(BINARY64)40else ifeq ($(UNAME_M),amd64)41 BINARY := $(BINARY64)42else ifeq ($(UNAME_M),i686)43 BINARY := $(BINARY32)44else ifeq ($(UNAME_M),i386)45 BINARY := $(BINARY32)46else ifeq ($(UNAME_M),armv5l)47 BINARY := $(BINARYARM5)48else ifeq ($(UNAME_M),armv6l)49 BINARY := $(BINARYARM6)50else ifeq ($(UNAME_M),armv7l)51 BINARY := $(BINARYARM7)52else53$(error "Build on $(UNAME_M) is not supported, yet.")54endif5556all: target/$(BINARY)5758target:59 mkdir -p $@6061ifeq ($(GOOS),windows)62release: 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.exe66else ifeq ($(GOOS),linux)67release: 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 fzf75else76release: 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 fzf80endif8182release-all: clean test83 GOOS=darwin make release84 GOOS=linux make release85 GOOS=freebsd make release86 GOOS=openbsd make release87 GOOS=windows make release8889$(SRC_LINK):90 mkdir -p $(shell dirname $(SRC_LINK))91 ln -s $(ROOT_DIR)/src $(SRC_LINK)9293$(VENDOR_LINK):94 mkdir -p $(shell dirname $(VENDOR_LINK))95 ln -s $(ROOT_DIR)/vendor $(VENDOR_LINK)9697$(GLIDE_LOCK): $(GLIDE_YAML)98 go get -u github.com/Masterminds/glide && $(GOPATH)/bin/glide install && touch $@99100test: $(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/util106107install: bin/fzf108109clean:110 rm -rf target111112target/$(BINARY32): $(SOURCES)113 GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@114115target/$(BINARY64): $(SOURCES)116 GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@117118# https://github.com/golang/go/wiki/GoArm119target/$(BINARYARM5): $(SOURCES)120 GOARCH=arm GOARM=5 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@121122target/$(BINARYARM6): $(SOURCES)123 GOARCH=arm GOARM=6 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@124125target/$(BINARYARM7): $(SOURCES)126 GOARCH=arm GOARM=7 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@127128target/$(BINARYARM8): $(SOURCES)129 GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@130131bin/fzf: target/$(BINARY) | bin132 cp -f target/$(BINARY) bin/fzf133134.PHONY: all release release-all test install clean