Git Product home page Git Product logo

golang-account-simple's Introduction

golang-account-simple

A simple Go web app to access mysql.

It's named account because it seemed like a simple enough example to use with an orm.

Make sure you understand go enough to have set your GOPATH. Recommended reading: https://github.com/alco/gostart#faq0

TLDR:

  • Make a directory named go. You must commit to forever more have anything related to go in this directory. Sorry, that's how go works. Set GOPATH= the fully qualified path to the go directory.
mkdir ~go && echo "export GOPATH=$HOME/go" >> ~/.bashrc && source ~/.bash_rc
  • Make the following directories in your go folder: bin, build, pkg, src
mkdir $GOPATH/bin && mkdir $GOPATH/build && mkdir $GOPATH/pkg && mkdir $GOPATH/src
  • Change into your src directory, and clone this package:
cd $GOPATH/src && git clone https://github.com/fimbulvetr/golang-account-simple.git

Make sure you have glide, a golang package manager installed.

Then, simply:

glide update

create your database on mysql:

CREATE DATABASE `account` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */;

create your table in the newly created account database:

CREATE TABLE `account` (
  `Id` int(11) NOT NULL,
  `Username` varchar(50) COLLATE utf8mb4_bin NOT NULL,
  `Type` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

create some sample data:

INSERT INTO `account` VALUES (2,'you',1);

Run:

ACCOUNT_DB_USER=$dbuser ACCOUNT_DB_PASS=$dbpassword ACCOUNT_DB_HOST=127.0.0.1:3306 ACCOUNT_DB_NAME=$db_name go run main.go

golang-account-simple's People

Contributors

fimbulvetr avatar

Watchers

 avatar  avatar

Forkers

snhwang

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.