Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Reorganize file layout. #2

Merged
merged 1 commit into from
Dec 10, 2012
Merged

Conversation

cyfdecyf
Copy link
Contributor

@cyfdecyf cyfdecyf commented Dec 9, 2012

It's better to follow the conventions on setting GOPATH and choosing import path as stated in How to Write Go Code. One benefit is that it's easier for the go command to fetch and install packages and binaries.

As this project contains one package and two executables, I guess it's better to choose an import path like github.com/<user>/shadowsocks-go.

This commit does the following:

  • Move the shadowsocks package source into shadowsocks directory
    • So the package can be imported as github.com/<user>/shadowsocks-go/shadowsocks
    • With the original organization, it's github.com/<user>/shadowsocks-go/src/shadowsocks which looks a little bit weird
  • Move the local and server executable source code into cmd directory (following the convention in go source tree), and append the shadowsocks prefix
  • Changed the shadowsocks package import statement in local.go and server.go to use the new path

With this change, shadowsocks can be easily installed with go get

go get github.com/<user>/shadowsocks-go/cmd/shadowsocks-server
go get github.com/<user>/shadowsocks-go/cmd/shadowsocks-local

Others who want to use the shadowsocks package can install it with

go get github.com/<user>/shadowsocks-go/shadowsocks

go build and go install also works under each subdirectory.

It's not possible (or maybe just difficult) to build shadowsocks inside it's own directory with this setting. But distribution should still be easy as go uses static linking and the executable itself is enough.

@clowwindy
Copy link
Contributor

I'm unfamiliar with Go and shadowsocks-go is only a little Go exercise. I didn't intend to maintain this version. But you keep making improvements. Thanks a lot! I think we can work together on the project to make it stable and usable enough. Since most users are non-programmers, Go binary files would be much useful than .py or .js files.

clowwindy added a commit that referenced this pull request Dec 10, 2012
@clowwindy clowwindy merged commit 1251447 into shadowsocks:master Dec 10, 2012
@cyfdecyf
Copy link
Contributor Author

I would be very glad to work with you on improving shadowsocks-go :)

@clowwindy
Copy link
Contributor

I'll transfer this project to organization shadowsocks.

@clowwindy
Copy link
Contributor

You can push directly to here now.

@cyfdecyf
Copy link
Contributor Author

Great!

@clowwindy
Copy link
Contributor

How to setup development building environment?

@cyfdecyf
Copy link
Contributor Author

  1. Install go from source code or using binary package
  2. Set GOPATH environment variable. This directory is your working space for go projects. More info in How to Write Go Code.
  3. go get github.com/shadowsocks/shadowsocks-go/shadowsocks This will clone the repository and install the shadowsocks package.

The source code should be in $GOPATH/src/github.com/shadowsocks/shadowsocks-go. Just git chcekout develop to get the development code.

@cyfdecyf cyfdecyf deleted the reorganize-code branch January 31, 2013 10:12
@clowwindy
Copy link
Contributor

So if I've changed some files and want to build again, I can just go install ./cmd/shadowsocks-local?

@cyfdecyf
Copy link
Contributor Author

go install has to be run in "the" directory containing the source file. I'm using sublime text and currently setup 3 projects for shadowsocks-go: one package and two executables.

Or edit Makefile, enable CGO and remove the -a flag to go install. After that you can just run make.

@clowwindy
Copy link
Contributor

OK. I got it.
I'm trying to add Travis CI test script.

@cyfdecyf
Copy link
Contributor Author

Great!
By the way, testscript/test.sh is the test script I used to test both the original and the rc4 encryption.

cappiewu pushed a commit to cappiewu/shadowsocks-go that referenced this pull request Apr 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants