{"id":15034813,"url":"https://github.com/zelenko/go","last_synced_at":"2026-03-10T22:03:13.902Z","repository":{"id":123857298,"uuid":"99169030","full_name":"zelenko/go","owner":"zelenko","description":"I incorporate these code snippets into my larger programming modules.","archived":false,"fork":false,"pushed_at":"2021-03-26T20:38:38.000Z","size":8134,"stargazers_count":40,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-06T11:03:51.162Z","etag":null,"topics":["go","golang","golang-examples","learning-golang"],"latest_commit_sha":null,"homepage":"https://zelenko.github.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zelenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-08-02T23:18:22.000Z","updated_at":"2024-06-21T23:51:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"d7c0d3b8-52e1-446a-a5c7-4fc5728bb400","html_url":"https://github.com/zelenko/go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zelenko/go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zelenko%2Fgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zelenko%2Fgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zelenko%2Fgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zelenko%2Fgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zelenko","download_url":"https://codeload.github.com/zelenko/go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zelenko%2Fgo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30357614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang","golang-examples","learning-golang"],"created_at":"2024-09-24T20:26:26.423Z","updated_at":"2026-03-10T22:03:13.882Z","avatar_url":"https://github.com/zelenko.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Exploring Golang features [![Go Report Card](https://goreportcard.com/badge/zelenko/go)](https://goreportcard.com/report/zelenko/go) \nYou can incorporate these code snippets into your larger programming modules. This repository is viewable on [sourcegraph.com](https://sourcegraph.com/github.com/zelenko/go).\n\n![Go](https://raw.githubusercontent.com/zelenko/go/master/37_html_template/pub/img/toby.jpg)\n\n## Contents\n\n| Name | Description |\n| :---- | :---- |\n| 00_persisting_go            | Installing Go, persisting on systemd, Upstart |\n| 01_data_type                | type, error, recursion, reference, sort, switch, type assertion |\n| 02_mongodb_aggregate_cli    | aggregate data from mongodb displayed in CLI |\n| 03_mongodb_find_sort_cli    | MongoDB Find All, Sort commands, results in CLI |\n| 04_get_url_variable         | Get \"FormValue\" variable from URL |\n| 05_mongodb_crud_cli         | Insert, Update, Drop, Find, Index commands, results in CLI |\n| 06_ajax_send_receive        | Two Ajax examples: read and write |\n| 07_one_page_template        | GO code and HTML template in one file |\n| 08_gowiki                   | Simple wiki example |\n| 09_todo_list_html           | Todo list with struct and HTML template. |\n| 10_mongodb                  | Mongodb query results on HTML page in one go file. |\n| 11_socket_send_receive      | Send/receive text between client/server via socket. |\n| 12_mgo_pipeline             | Mongodb pipeline query saved in one go file |\n| 13_qr_barcode               | QR code generator displays PNG image in browser. |\n| 14_read_txt_file            | Compare ways to process TXT file |\n| 15_png_or_svg_barchart      | generate bar chart, PNG or SVG |\n| 16_drop_down_menu_form      | Form /w drop down menu, template with sub-templates |\n| 17_mysql_user_login         | MySQL for user registration, login, and user list. |\n| 18_cookie_authentication    | Authentication with cookies. |\n| 19_os_global_variables      | Displaying all global system variables. |\n| 20_mongodb_crud             | Mongodb CRUD with REST using httprouter \u0026 HTML templates |\n| 21_httprouter_template      | html template with httprouter and ServeFiles |\n| 22_mongodb_crud_rest_html   | Mongodb CRUD with REST using httprouter \u0026 HTML templates |\n| 23_file_uploader            | Upload file and save on server |\n| 24_calculate_time           | Time related features |\n| 25_https_static_files       | Serve HTTP and HTTPS w/ NotFound for static files |\n| 26_url_not_found_handler    | Custom Not Found handler. |\n| 27_mongodb_bulk_upsert      | Mongodb bulk insert from TXT file |\n| 28_markdown                 | Generate Markdown using blackfriday |\n| 29_go_crud_json_api         | REST API using JSON with httprouter.  JavaScript is used to view, create, edit, and delete records. |\n| 30_mongodb_crud_json_api    | REST API using JSON, httprouter, and toml, i/o to MongoDB |\n| 31_send_email               | Send email with attachment |\n| 32_colorful_cli             | Create colorful CLI |\n| 33_testing                  | Testing package example |\n| 34_channels                 | Buffered/unbuffered channels, forking channel, ranging over closed channel. |\n| 35_mongodb_pipeline_page    | One page MGO aggregation with pipeline |\n| 36_concurrency_channel      | Channel, waiting, concurrency, sleep, close, count, queue |\n| 37_html_template            | Simple html template with Go |\n| 38_url_request_JSON         | Convert data to/from JSON, get and parse file from URL |\n| 39_read_directory_content   | List files adn sub folders in a given folder |\n| 40_cron_scheduler           | Schedule processes |\n| 41_cli_arguments            | Run cli utility with options using os.Args |\n| 42_upload_many_files        | Upload multiple files from browser form to folder on a server. |\n| 43_resize_jpg_png_image     | Resize images |\n| 44_csv_file                 | Read and write to CSV file.  Parse CSV file to slice of objects. |\n| 45_image_exif_data          | Get image attributes for each image in a folder. |\n| 46_video_capture            | Capture video from web camera and display live. |\n| 47_download_slice_as_csv    | Download link generates CSV or Tab Delimited file that can be saved localy on your computer. |\n| 48_keyboard_driver          | Testing IOT devices |\n| 49_constructor              | Example creating new package with allocation/constructor that accepts multiple types using interface. Experimenting with Readers and Writers. |\n| 50_golf_framework           | A fast, simple and lightweight micro-web framework for Go |\n| 51_blur_image               | Blur, Rotate, and Generate Thumbnails. |\n| 52_jpg_image_watermark      | Add watermark to image |\n| 53_regular_expression       | Validation, Find and replace, security |\n| 54_rotate_image             | Image rotation in degrees from 1 to 360. |\n| 55_html_template_std_lib    | HTML template using standard library packages |\n| 56_html_formatter           | Work in similar fashion as `go fmt`, but on HTML files. |\n| 57_valid_interface\t\t  | Interface as parameter. |\n| 58_GO_HTML_template         | Go HTML template examples. |\n| 59_zip_and_unzip            | Example for archive/zip package. |\n| 60_http_response_as_file    | HTTP handler responds with a copied file. |\n| 61_logging_middleware       | Save logs and error logs to file or database. |\n| 62_download_progress        | Progress shown on CLI. |\n| 63_graphql_todo_example     | One file GraphQL example. |\n| 64_\t\t\t              |  |\n| 65_books_example            | MongoDB CRUD example. |\n| 66_server_sent_events       | Live logs (events) from server to browser using the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) HTML interface. |\n| 67_stringutil\t\t\t\t  | Reverse a string, test included |\n| 68_iota                     | Iota identifier is used in const declarations to simplify definitions of incrementing numbers. |\n| 69_JSON                     | JSON input/output examples |\n\n## The proper way to copy a slice\n```GO\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\ta := []string{\"a\", \"b\", \"c\", \"d\"}\n\te := make([]string, len(a))\n\tcopy(e, a)\n\tfmt.Println(e)\n}\n```\n## How to find out the data type?\n```GO\n// Figure out what type it is: maps, slices, or arrays!\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n)\n\nfunc main() {\n\n\t// Declaring local variables\n\tmap1 := map[string]string{\"name\": \"John\", \"desc\": \"Golang\"}\n\tmap2 := map[string]int{\"apple\": 23, \"tomato\": 13}\n\tslice1 := []int{1, 2, 3}\n\tarray1 := [3]int{1, 2, 3}\n\t// var m map[string]int\n\t// m = make(map[string]int)\n\t// More info Here: https://blog.golang.org/go-maps-in-action\n\n\t// Type, such as map[string]string, []int, [3]int\n\tfmt.Println(\"map1:\", reflect.TypeOf(map1))\n\tfmt.Println(\"map2:\", reflect.TypeOf(map2))\n\tfmt.Println(\"slice1:\", reflect.TypeOf(slice1))\n\tfmt.Println(\"array1:\", reflect.TypeOf(array1))\n\n\t// Value, such as map, slice, array.\n\tfmt.Println(\"map1:\", reflect.ValueOf(map1).Kind())\n\tfmt.Println(\"map2:\", reflect.ValueOf(map2).Kind())\n\tfmt.Println(\"slice1:\", reflect.ValueOf(slice1).Kind())\n\tfmt.Println(\"array1:\", reflect.ValueOf(array1).Kind())\n\n\t// True/False statement inside Printf\n\tfmt.Printf(\"%v is a map? %v\\n\", map1, reflect.ValueOf(map1).Kind() == reflect.Map)\n\tfmt.Printf(\"%v is a map? %v\\n\", map2, reflect.ValueOf(map2).Kind() == reflect.Map)\n\tfmt.Printf(\"%v is a map? %v\\n\", slice1, reflect.ValueOf(slice1).Kind() == reflect.Map)\n}\n```\n![Go](http://farm4.staticflickr.com/3774/11740822616_e435d02a54_o.gif)\n\n\u003e In Go, the code does exactly what it says on the page.\n\n\u003e It’s the simplicity that makes Go awesome.\n\n\u003e Go: Statically typed yet expressive language with a focus on concurrency.\n\n\u003e Go strives to keep things small and beautiful.\n\n\u003e What I would have done in Python, Java, Ruby, PHP, C, C# or C++, I’m now doing in Go.\n\n\u003e The code must be like a piece of music.\n\n\u003e Code less, compile quicker, execute faster.\n\n\u003e Any of your code that you haven’t looked at for 6 or more months may as well have been written by someone else.\n\n\u003e General guideline: accept interfaces, return structs\n\n\u003e Go is simple but not easy.\n\n# TODO :\n- [X] MongoDB connection\n- [X] MySQL connection\n- [X] Resize Images\n- [X] Set/Get Image tags\n- [X] SQLite connection\n- [X] Postgres connection\n- [X] React frontend\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzelenko%2Fgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzelenko%2Fgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzelenko%2Fgo/lists"}