Building tyk from source and learning its components

I am able to run the tyk gateway on ubuntu, i invoke the tyk gateway as a service i ubuntu.

The gateway is installed at /opt/tyk-gateway , i’ve noticed that most files and folders are missing from in this location. i.e. the server.go file

I’ve downloaded the full source code from the tyk github repo, I was wondering how i can build the gateway entirely from source and be able to experiment with the code base in a process of learning how the components are wired, my goal is to understand the code and the philosophy so i can extend the gateway and/or start contributing.

Is there a somewhere in the docs where i can refer to that shows how to build a dev environment for the gateway ? Thanks

Hi salimsaid,

I’m not a golang developer myself (still learning) but following the basic approaches to building a go application I can successfully build tyk and start it. I basically had a read of this How to Write Go Code - The Go Programming Language and used go to fetch dependencies and build it as per the below.

#:~/go/src$ go env | grep GOPATH
GOPATH="/home/chris/go"
#:~$ cd /home/chris/go
#:~/go$ cd src/
#:~/go/src$ git clone https://github.com/TykTechnologies/tyk        
Cloning into 'tyk'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 29959 (delta 17), reused 13 (delta 12), pack-reused 29934
Receiving objects: 100% (29959/29959), 155.07 MiB | 5.05 MiB/s, done.
Resolving deltas: 100% (18646/18646), done.
#:~/go/src$ cd tyk/
#:~/go/src/tyk$ go get -v
go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src;
        ignoring go.mod;
        see 'go help modules'
github.com/TykTechnologies/tyk (download)
#:~/go/src/tyk$ go build -v
#:~/go/src/tyk$ ls -l tyk
-rwxrwxr-x 1 chris chris 42229600 Apr  1 11:58 tyk
#:~/go/src/tyk$ ./tyk 
[Apr 01 11:58:33]  INFO main: Tyk API Gateway v2.9.3
[Apr 01 11:58:33]  WARN No config file found, writing default to tyk.conf
[Apr 01 11:58:33]  INFO Loading default configuration...
[Apr 01 11:58:33]  WARN checkup: File descriptor limit 1024 is too low for production use. A minimum of 80000 is recommended.
...
...

While I’m sure there are various best practises that can be applied atop of this, the documentation with the language environment seems pretty good.

Hopefully that helps.

1 Like

Thanks @chris.f this is helpful.

1 Like