GithubHelp home page GithubHelp logo

sample-go-app's Introduction

CVWO Assignment Sample Golang App

This sample Golang app is provided to help you experiment and practice web development fundamentals. It shows how certain functionality can be implemented. However, do note that this is far from a model example. After all, we want to see how you maximise your learning in web development and good software development practices.

Getting Started

Installing Go

Download and install Go by following the instructions here.

Running the app

  1. Fork this repo.
  2. Clone your forked repo.
  3. Open your terminal and navigate to the directory containing your cloned project.
  4. Run go run cmd/server/main.go and head over to http://localhost:8000/users to view the response.

Navigating the code

This is the main file structure. Note that this is simply one of various paradigms to organise your code, and is just a bare starting point.

.
├── cmd
│   ├── server
├── internal
│   ├── api         # Encapsulates types and utilities related to the API
│   ├── dataacess   # Data Access layer accesses data from the database
│   ├── database    # Encapsulates the types and utilities related to the database
│   ├── handlers    # Handler functions to respond to requests
│   ├── models      # Definitions of objects used in the application
│   ├── router      # Encapsulates types and utilities related to the router
│   ├── routes      # Defines routes that are used in the application
├── README.md
├── go.mod
└── go.sum

Main directories/files to note:

  • cmd contains the main entry point for the application
  • internal holds most of the functional code for your project that is specific to the core logic of your application
  • README.md is a form of documentation about the project. It is what you are reading right now.
  • go.mod contains important metadata, for example, the dependencies in the project. See here for more information
  • go.sum See here for more information

Try changing some source code and see how the app changes.

Next Steps

  • This project uses go-chi as a web framework. Feel free to explore other web frameworks such as gin-gonic. Compare their pros and cons and use whatever that best justifies the trade-offs.
  • Read up more on the MVC framework which this code is designed upon.
  • Sometimes, code formatting can get messy and opiniated. Do see how you can incoporate linters to format your code.

sample-go-app's People

Contributors

emilyong avatar joeng03 avatar richdom2185 avatar tituschewxj avatar

Watchers

 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.