Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Minimal SOCKS5 proxy server in Go
// For use in the tutorial at
// Source:
// To compile, run once: go get
// then run: go run simplesocks5proxyserver.go
package main
import (
func main() {
// Create a SOCKS5 server
config := &socks5.Config{
Logger: log.New(os.Stdout, "SOCKS5Server", log.LstdFlags),
server, err := socks5.New(config)
if err != nil {
fmt.Print("Listening on\n");
fmt.Print("Press Ctrl+C to interrupt: ");
// Create SOCKS5 proxy on localhost port 1080
if err := server.ListenAndServe("tcp", ""); err != nil {

This comment has been minimized.

Copy link

@derekmahar derekmahar commented May 16, 2020

@simos, what should I do to resolve this compilation error? The Go compiler apparently misinterprets the go-socks5 module import as a local import.

derek@derek-TB350-BTC:~/Projects/go/35c6aa259cab05fd56c19ad6b0cfdd0f$ go run simplesocks5proxyserver.go
simplesocks5proxyserver.go:11:5: cannot find package "" in any of:
        /snap/go/5759/src/ (from $GOROOT)
        /home/derek/go/src/ (from $GOPATH)

This comment has been minimized.

Copy link
Owner Author

@simos simos commented May 16, 2020

@derekmahar, indeed, you get this error when you build this Go code.

Run first,

go get

and then you should be able to go run successfully.


This comment has been minimized.

Copy link

@derekmahar derekmahar commented May 17, 2020

Thank you! That fixed the problem.

Note that go get downloaded the package into ~/go/pkg:

derek@derek-TB350-BTC:~/Projects/go/35c6aa259cab05fd56c19ad6b0cfdd0f$ go get
derek@derek-TB350-BTC:~/Projects/go/35c6aa259cab05fd56c19ad6b0cfdd0f$ find ~/go/pkg/linux_amd64/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.