If you want to try golang's webserver/database for free without installing anything.
This isnt my project and I didnt build anything but it took me these 2 new years days off to finally figure all this out. Honestly db drivers and setting up a webserver and a database with a new language is kinda challenging and can take such a long time to finely get it working. I wanted to share this because it was after 2 days of trying and researching and everything to finally get this working. Im affiliated with no one, just a tired noob
First go to cloud9 IDE and signup its free https://c9.io/
Head over to this resource for exact code
https://dinosaurscode.xyz/go/2016/06/19/golang-mysql-authentication/
In the terminal do the following to get the project.
go get golang.org/x/crypto/bcrypt
then do this....
go get github.com/go-sql-driver/mysql
then do this in the terminal
git clone https://github.com/xDinomode/Go-Signup-Login-Example-MySQL.git
Change the code for the username/password/database name to what cloud9 gives you.
db, err = sql.Open("mysql", "<root>:<password>@/<dbname>")
// Replace with
db, err = sql.Open("mysql", "myUsername:myPassword@/myDatabase")
Usually cloud9's username is your username and leave the password blank if you didnt assign one and just do the following in cloud9 IDE terminal to find the database so that the code becomes
db, err = sql.Open("mysql", "yourusername:@/mysql")
Then do the following terminal commands in cloud9
mysql-ctl install
mysql-ctl cli
show databases;
use mysql;
show tables;
Then run this sql to create the table.
CREATE TABLE users( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50), password VARCHAR(120) );
If you need help with mysql then here https://docs.c9.io/docs/setup-a-database
Then to preview the server using the following URL after hitting preview
https://yourprojectname-yourusername.c9users.io/
By replacing "yourprojectname" with your project name and "yourusername" with your username.
Remember to put in the terminal "go build" if you make a change and to see the results do "go run signup.go" and to rerun the database you have to put in the terminal "mysql-ctl cli"
The page should appear.
If you need a database interface to make it easier to read use phpmyadmin by running this in the terminal.
phpmyadmin-ctl install
Also, once you have this all setup, just save the project and go back into your dashboard and use "clone" so that you never have to do any of this ever again.
Let me know if you have trouble with any of this or if you are able to get the drivers working and connected on that gogland IDE because I was not able to.
