Code Monkey home page Code Monkey logo

go-mysql-webservice's Introduction

go-mysql-webservice

Another example go webservice with mysql data

Prepare Database

You should have install mysql in Your server or PC tseting

Create database in mysql for example restdb, with structure:

CREATE TABLE IF NOT EXISTS `employee` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `birthday` date DEFAULT NULL,
  `photo` varchar(255) DEFAULT NULL,
  `created_at` int(11) DEFAULT NULL,
  `updated_at` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=8;

Add sampel data

INSERT INTO `employee` (`id`, `name`, `email`, `birthday`, `photo`, `created_at`, `updated_at`) VALUES
(1, 'Jayda Douglas', '[email protected]', '1983-12-18', 'images/3c6bb1a0f9559dc5f35b5c4ff0af62a1.jpg', 1448838415, NULL),
(2, 'Arne Cummings', '[email protected]', '1976-06-03', 'images/7aa5030f593d9fdbaf83928477581342.jpg', 1448838422, NULL),
(3, 'Ludwig Daniel', '[email protected]', '1937-07-25', 'images/16fe84f059901ac62575d0878233ff45.jpg', 1448838436, NULL),
(4, 'Devan Prosacco', '[email protected]', '1969-11-14', 'images/113fa3eb20213b3a95f35f27e0ca5dc1.jpg', 1448838443, NULL),
(5, 'Jesse Sauer', '[email protected]', '1983-12-18', 'images/978cb1271da894dbd3795e35de188585.jpg', 1448838458, NULL),
(6, 'Antonietta Adams Jr.', '[email protected]', '1928-02-29', 'images/b102b35a0483c4a55f4f19b79834952a.jpg', 1448838465, NULL),
(7, 'Corine Grady', '[email protected]', '1983-12-18', 'images/c92658fcd87b5db8c88304c4ffc94ca5.jpg', 1448838466, NULL);

Step by step

  1. You should have install go https://golang.org/doc/install

  2. Via terminal, change Your current directory to src, then

  3. Download Source You may use git

git clone https://github.com/hscstudio/go-mysql-webservice

or You can download manually

  1. Install dependency
cd go-mysql-webservice
go get
  1. Run Go
go run rest.go
  1. Access in browser http://localhost:8080/employee

Enjoy

Hafid Mukhlasin

go-mysql-webservice's People

Contributors

hscstudio avatar

Watchers

James Cloos avatar Rehan Kodekar 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.