Giter Club home page Giter Club logo

lynx's Introduction

Lynx

Label Lab system Back-end api via go lang

Before Started

Most important

  1. Please create your own branch for your features. If you want to merge your codes into main branch, please create a new pull request and contact project owner or other team members to review your codes.
  2. If you need dramatic refactoring, please discuss with code owners.

For Mac users

  1. Make sure you have golang installed:
    • Install through homebrew: brew install golang
    • Check whether golang is successfully installed: go version
  2. Go environment:
    • Step 1: In your terminal (take zsh for example), create a directory specially for Go projects, you have to put and run your Go projects in this directory. For example, in your Documents directory:
      $ mkdir go-projects
    • Step 2: Set Go Paths environment variables. Feel free to choose any one from Vim version and terminal version.
      • Vim version:
        1. terminal command: $ vim ~/.zshenv
        2. In your vim:
        export GOROOT=/usr/local/go
        export GOPATH=~/Documents/go-projects
        export PATH=$PATH:$GOPATH/bin
        export PATH=$PATH:$GOROOT/bin
        
        • Remind: GOROOT would be where you installed your golang. Can be checked by $ which go
      • Terminal version:
        • Termianl commands:
          $ echo 'export GOPATH=~/Documents/go-projects' >> ~/.zshenv
          $ echo 'export GOROOT=/usr/local/go' >> ~/.zshenv
          $ echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.zshenv
          $ echo 'export PATH=$PATH:$GOROOT/bin' >> ~/.zshenv
          
      Check whether you have successfully finished this step by typing follwoing command in a new terminal window.(no matter which version you choose to set variables.)
      $ echo $GOPATH (should show ~/Documents/go-projects) (can deduce the rest from this)
    • Step 3: Create go workspace by command:
      $ mkdir -p $GOPATH $GOPATH/src $GOPATH/pkg $GOPATH/bin
    • Step 4: Clone or create your Go projects in $GOPATH/src. Since this repo have absolute directory github.com/..., your have to create a directory named github.com in $GOPATH/src, and then clone this repo in github.com.
    • Step 5: Install packages. You can use $ go mod download.
    • Step 6: Run this project, use go run . or gin -i run .
    • Step 7: To check whether server is successfully running, you can try: $ curl -X GET 'http://127.0.0.1:9090' in a new terminal window.
    • Ref
  3. Some file/directory notes:
    • main.go: main function that run this server.
    • route.go: routes of restful api can be found here.
    • /controller: main logics here.
    • /service: connect to db and do CRUDs.
    • /models: db schemas
    • /db: deal with mongodb connection.
    • others: are not important.

Docker access method

  1. make sure you have docker installed.
  2. After cloning this repo, use the following commands (in this project directory) to run the server:
    $ docker build -t 'bilab-backend' .
    $ docker run -p 9090:9090 bilab-backend
    
  3. Access api with: http://localhost:9090/articles

Execute

  • To run the server, you can use
go mod download
go run .
  • If you need live-reload, install gin: $ go get github.com/codegangsta/gin. Then run this repo by: $ gin -i run .. Ref

Connect to Linux Server (temp)

To check the error log or CI/CD process.

  • make ssh connection: ssh [email protected] and enter the password.
  • attach to tmux session: tmux attach -t golang_server
  • if Server is shutdown, run: bash server.sh to re-run the server.

Tutorial Recommandation

lynx's People

Contributors

frank93011 avatar shihyun0130 avatar francis1572 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.