{"id":22794525,"url":"https://github.com/blue-davinci/go-snip","last_synced_at":"2026-05-05T23:33:28.563Z","repository":{"id":240059227,"uuid":"799579774","full_name":"Blue-Davinci/Go-Snip","owner":"Blue-Davinci","description":"      Go-Snip is a platform designed for sharing snippets of code, stories, posts, and more. It's a community where users can share their knowledge and learn from each other.       With Go-Snip, you can easily save and organize your snippets for personal use or share them with the community.","archived":false,"fork":false,"pushed_at":"2024-05-16T13:43:19.000Z","size":4675,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T19:59:49.048Z","etag":null,"topics":["backend","golang","html","htmx","javascript"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Blue-Davinci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-12T15:07:59.000Z","updated_at":"2024-07-04T20:44:18.000Z","dependencies_parsed_at":"2024-05-16T14:38:09.761Z","dependency_job_id":"348c67cf-6d42-4444-91f4-8db574014a76","html_url":"https://github.com/Blue-Davinci/Go-Snip","commit_stats":null,"previous_names":["blue-davinci/go-snip"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blue-Davinci%2FGo-Snip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blue-Davinci%2FGo-Snip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blue-Davinci%2FGo-Snip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Blue-Davinci%2FGo-Snip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Blue-Davinci","download_url":"https://codeload.github.com/Blue-Davinci/Go-Snip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246357685,"owners_count":20764361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","golang","html","htmx","javascript"],"created_at":"2024-12-12T04:09:05.782Z","updated_at":"2026-05-05T23:33:23.544Z","avatar_url":"https://github.com/Blue-Davinci.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"\" rel=\"noopener\"\u003e\n \u003cimg width=200px height=200px src=\"https://i.imgur.com/6wj0hh6.jpg\" alt=\"Project logo\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003eGo-Snip\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Status](https://img.shields.io/badge/status-active-success.svg)]()\n[![GitHub Issues](https://img.shields.io/github/issues/Blue-Davinci/Go-Snip.svg)](https://github.com/Blue-Davinci/Go-Snip/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/Blue-Davinci/Go-Snip.svg)](https://github.com/Blue-Davinci/Go-Snip/pulls)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\n\n\u003c/div\u003e\n\n---\n\n\u003cp align=\"center\"\u003e A Fullstack Go + HTML + Vanilla JS Application for Snippet Generation and Sharing.\n    \u003cbr\u003e \n\u003c/p\u003e\n\n## 📝 Table of Contents\n\n- [About](#about)\n- [Getting Started](#getting_started)\n- [Deployment](#deployment)\n- [Usage](#usage)\n- [Built Using](#built_using)\n- [TODO](./TODO.md)\n- [Contributing](../CONTRIBUTING.md)\n- [Authors](#authors)\n- [Acknowledgments](#acknowledgement)\n\n## 🧐 About \u003ca name = \"about\"\u003e\u003c/a\u003e\n\n      Go-Snip is a platform designed for sharing snippets of code, stories, posts, and more. It's a community where users can share their knowledge and learn from each other.\n      With Go-Snip, you can easily save and organize your snippets for personal use or share them with the community. \n      Go-Snip also offers login capabilities, allowing users to create their own personal space for storing and managing snippets. You can keep your snippets private or share them with the Go-Snip community.\n\n## 🏁 Getting Started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.\n     \n### Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n\n- You have installed the latest version of [Go](https://golang.org/dl/), which is the programming language used in this project.\n- You have installed [MySQL](https://dev.mysql.com/downloads/installer/), which is the database used in this project.\n- You have installed [Git](https://git-scm.com/downloads), which is used for version control.\n\nTo confirm that you have installed Go and Git correctly, open a new terminal and run the following commands:\n\n```bash\ngo version\ngit --version\n```\n### Installing \u003ca name = \"installing\"\u003e\u003c/a\u003e\n\nFollow these steps to get a development environment running:\n\n1. **Clone the repository** from GitHub:\n\n    ```bash\n    git clone https://github.com/blue-davinci/gosnip.git\n    ```\n\n2. **Navigate to the project directory**: Use the `cd` command to navigate to the projet directory:\n\n    ```bash\n    cd gosnip\n    ```\n\n3. **Install the project dependencies**: The Go tools will automatically download and install the dependencies listed in the `go.mod` file when you build or run the project. To download the dependencies without building or running the project, you can use the `go mod download` command\n\n    ```bash\n    go mod download\n    ```\n\n4. **Set up the database**. First, start your MySQL server. You can,\nview the Migrations and execute them like so:\n\n    ```bash\n    migrate -path=migrations/test_db -database='mysql://`your_username`:`your_password`@/`your_database`?parseTime=true' up\n    ```\n  Migration tool used :- `golang migrate`\n  If you need to understand them, you can alsways open them and check what they do. Database creation, table creations and sample data insertions.\n\n5. **Build the project**: You can build the project using the `go build` command:\n\n    ```bash\n    go build\n    ```\n  An alternative is using the MAKEFILE, to just build immediately:\n    ```bash\n  make build/api\n  ```bash\n    make build/api\n  ```\n\n\n6. **Run the project**: You can run the project using the `go run` after navigating to `cmd\\web\\` directory:\n\n    ```bash\n    go run ./cmd/web\n    ```\n  Alternatively, run the make commands for the same:\n  ```bash\n    make build/exe\n  ```\n\nRemember to replace `your_username` and `your_database` with your actual MySQL username and the name of the database you want to create. If your MySQL server is password-protected, you'll be prompted to enter your password after running the `mysql` commands.\n\n## 🔧 Running the tests \u003ca name = \"tests\"\u003e\u003c/a\u003e\n\nThis project uses Go's built-in testing package. To run the tests, follow these steps:\n\n1. Open a terminal in the project's root directory.\n\n2. Run the following command to execute the tests:\n\n    ```bash\n    go test ./...\n    ```\n\n  This command will recursively run all tests in the project.\n\n  To run tests for the `handlers` package, you would use:\n```bash\n    go test ./cmd/web\n ```\n\n### Break down into end to end tests \u003ca name = \"test_break\"\u003e\u003c/a\u003e\n\nEnd to end tests are types of tests that simulate a user's journey through encompassing the routimg, middleware and handlers within our application.\n\nIn our application, end-to-end testing is performed using the httptest.NewTLSServer() function. This function creates an instance of httptest.Server that allows us to make HTTPS requests, effectively simulating a real server for testing purposes.\n\nWe start by creating a new instance of our application struct, which currently includes the following mock application dependancies:\n```\n\t\tlogger:         a mock logger,\n\t\tsnippets:       a mock interface pointing to our snippet model mock\n\t\tusers:          a mock interface pointing to our user model mock\n\t\ttemplateCache:  holds a cache of our templates,\n\t\tformDecoder:    a data object that holds our form data,\n\t\tsessionManager: our session manager,\n```\n\nThe test server's network address is stored in the ts.URL field. We use this address to make HTTP requests against the server. For example, we can use ts.Client().Get() to send a GET request to the /ping endpoint. This method returns an http.Response struct, which contains the server's response.\n\n```\nrs, err := ts.Client().Get(ts.URL + \"/ping\")\nif err != nil {\n    t.Fatal(err)\n}\n\n// We can then check the value of the response status code and body \nassert.Equal(t, rs.StatusCode, http.StatusOK)\n\ndefer rs.Body.Close()\n\nbody, err := io.ReadAll(rs.Body)\nif err != nil {\n    t.Fatal(err)\n}\n\nbody = bytes.TrimSpace(body)\nassert.Equal(t, string(body), \"OK\")\n```\n\n***Sample Output**: sample output of the above test:\n```\n=== RUN   TestPing\nRunning:  TestPing\n{\"level\":\"INFO\",\"time\":\"0000-00-00Z90:00:000\",\"message\":\"127.0.0.1:55504 - HTTP/1.1 GET /ping\"}\n--- PASS: TestPing (0.01s)\nPASS\nok      github.com/blue-davinci/gosnip/cmd/web  0.972s\n```\n\n### Test Structure\n\n- The individual tests can be found as files ending with `*_test.go`\n- `testutils_test.go` holds utility functions that we can are using for our tests\n- `internal\\models\\mocks` holds the mock models for our snippets and user code.\n\n## 🎈 Usage \u003ca name=\"usage\"\u003e\u003c/a\u003e\n\nOnce you have the application up and running (refer to the [installation instructions](#installing)), you can start using it by navigating to `localhost:\u003cport\u003e` in your web browser, where `\u003cport\u003e` is the port number the application is running on.\n\nHere's a brief overview of the application's functionality:\n\n- **Account Creation**: Click on the 'Sign Up' button to create a new account. You'll need to provide some basic information, such as your username and password.\n\n- **Logging In**: Once you've created an account, you can log in by clicking on the 'Log In' button and entering your account details.\n\n- **Creating Snippets**: After logging in, you can create a new snippet by clicking on the 'Create Snippet' button. You'll need to provide a title and the content for your snippet.\n\n- **Viewing Account Details**: You can view your account details by clicking on your username in the top-right corner of the screen.\n\n- **Viewing Snippets**: All users, including those who aren't logged in, can view snippets that have been posted by navigating to the 'Snippets' page.\n\nRemember to replace `\u003cport\u003e` with the actual port number that your application is running on.\n- **Security Features:** Protections included are:\n                    - CSRF Protection\n                    - Session management\n                    - XSS protection\n                    - Self Signed TLS Certificates\n                    - HTTPS server\n                    - Connection Timeouts + Other HTTPS Settings\n\n## 🚀 Deployment \u003ca name = \"deployment\"\u003e\u003c/a\u003e\n\n{{To Do}}\n\n## ⛏️ Built Using \u003ca name = \"built_using\"\u003e\u003c/a\u003e\n- [Golang](https://golang.org/) - Language\n- [MySQL](https://dev.mysql.com/) - Database\n- [NodeJs](https://nodejs.org/en/) - Server Environment\n- HTML + JS.. (refer to the [installation instructions](#installing))\n\n\n## ✍️ Authors \u003ca name = \"authors\"\u003e\u003c/a\u003e\n\n- [@ble_davinci](https://github.com/blue-davinci) - project\n\n\n## 🎉 Acknowledgements \u003ca name = \"acknowledgement\"\u003e\u003c/a\u003e\n\n- Hat tip to anyone whose code was used\n\n## 📚 References \u003ca name = \"references\"\u003e\u003c/a\u003e\n- [Go Documentation](https://golang.org/doc/): Official Go documentation and tutorials.\n- [PostgreSQL Documentation](https://www.postgresql.org/docs/): Official PostgreSQL documentation.\n- [Go database/sql tutorial](http://go-database-sql.org/): Tutorial on using Go's database/sql package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblue-davinci%2Fgo-snip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblue-davinci%2Fgo-snip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblue-davinci%2Fgo-snip/lists"}