{"id":27294567,"url":"https://github.com/nerdalert/go-netops-tutorials","last_synced_at":"2025-07-13T08:09:51.286Z","repository":{"id":25893734,"uuid":"29334251","full_name":"nerdalert/go-netops-tutorials","owner":"nerdalert","description":"Simple Code Snippet Examples for networkstatic.net Go Blog Posts","archived":false,"fork":false,"pushed_at":"2015-02-02T23:06:14.000Z","size":236,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T22:53:26.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerdalert.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}},"created_at":"2015-01-16T05:29:57.000Z","updated_at":"2025-01-05T21:38:10.000Z","dependencies_parsed_at":"2022-07-27T05:46:23.838Z","dependency_job_id":null,"html_url":"https://github.com/nerdalert/go-netops-tutorials","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nerdalert/go-netops-tutorials","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdalert%2Fgo-netops-tutorials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdalert%2Fgo-netops-tutorials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdalert%2Fgo-netops-tutorials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdalert%2Fgo-netops-tutorials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerdalert","download_url":"https://codeload.github.com/nerdalert/go-netops-tutorials/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdalert%2Fgo-netops-tutorials/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265108514,"owners_count":23712466,"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":[],"created_at":"2025-04-11T22:53:24.954Z","updated_at":"2025-07-13T08:09:51.260Z","avatar_url":"https://github.com/nerdalert.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-netops-tutorials\nSimple Code Snippet Examples for networkstatic.net Go Blog Posts\n\n-Post at http://networkstatic.net/golang-network-ops/\n\n### Example usage and output\n\n*go run hello_world.go*\n\n\tHello World\n\n*go-netops-tutorials # go run exec_example.go*\n\n\t2015/02/02 15:18:01 The results are -----\u003e  PING 8.8.8.8 (8.8.8.8): 56 data bytes\n\t64 bytes from 8.8.8.8: icmp_seq=0 ttl=56 time=38.111 ms\n\t64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=37.963 ms\n\t\n\t--- 8.8.8.8 ping statistics ---\n\t2 packets transmitted, 2 packets received, 0.0% packet loss\n\tround-trip min/avg/max/stddev = 37.963/38.037/38.111/0.074 ms\n\t\n\t2015/02/02 15:18:01 The date is --\u003e Mon Feb  2 15:18:01 EST 2015\n\t\n*go run resolve_dns_example.go*\n\n\tdocker.io resolves to --\u003e  162.242.195.84\n\t\n\tbadH0stN@me.c0m doesnt resolve and prints a nil pointer, thats uglies --\u003e  \u003cnil\u003e\n\t\n\t2015/02/02 15:18:08 lookup failed for [ badH0stN@me.c0m ]\n\t\n\topenvswitch.org resolves to --\u003e  69.56.251.103\n\n*go-netops-tutorials # go run struct_examples.go*\n\n\t### struct as a pointer ###\n\t{\n\t\t\"Network\": \"10.1.1.0\",\n\t\t\"Mask\": 24\n\t}\n\t### struct as a literal ###\n\t{\n\t\t\"Network\": \"10.1.2.0\",\n\t\t\"Mask\": 30\n\t}\n\t### struct as a pointer ###\n\t{\n\t\t\"Network\": \"10.1.1.0\",\n\t\t\"Mask\": 28\n\t}\n\n\n**Note:** In these examples, each go file contains a main() function which is the starting point of execution that enables each go file to be run individually your IDE may complain about there being \n\nIf you run:\n\n*go build ./*\n\nYou will get the following complaints:\n\n\t github.com/nerdalert/go-netops-tutorials\n\t./hello_world.go:5: main redeclared in this block\n\t\tprevious declaration at ./exec_example.go:6\n\t./resolve_dns_example.go:9: main redeclared in this block\n\t\tprevious declaration at ./hello_world.go:5\n\t./struct_examples.go:14: main redeclared in this block\n\t\tprevious declaration at ./resolve_dns_example.go:9\n\nTo get rid of those errors you can rename some of the main() functions to a new name. Those functions could then be called from a single main() function in the root directory. I think starting out having a single file to experiment with is the simplest approach to hack for beginners.\n\nAlso, feel free to send pull requests in to learn how to do pull requests. Here is a quick how-to for pull requests. There are quite a few ways to do so, but it can be daunting for first timers so hopefully an example helps a bit. Also checkout the [Github Pull Request Help](https://help.github.com/articles/using-pull-requests/)\n\n### How to create a Pull Request\n\nClone this repository\n\ngit clone git@github.com:socketplane/socketplane\n\n\tClick the fork button at the top of the page.\n \nTo create a fork using ssl, [setup your ssh keys](https://help.github.com/articles/generating-ssh-keys/) and then clone using the following. Be sure to replace my username w/your username. \n\n\tgit clone git@github.com:\u003cyour github username\u003e/go-netops-tutorials.git\n\nAlternatively you can use https to clone:\n\n\thttps://github.com/nerdalert/go-netops-tutorials.git\n\nCreate a branch for your work. This creates a new branch that is basically a copy of the worksapce:\n\n\n\t# For bugs\n\tgit checkout -b bug/42\n\t# For long-lived feature branches\n\tgit checkout -b feature/something-cool\n\nView the branch\n\n\tgit branch -a\n\t\nMake a change in a file and view changes you have made:\n\n\tgit status\n\tgit diff \u003cbranchname\u003e\n\texample: git diff master\n\nMake your changes and commit\n\n\tgit add --all\n\tgit commit -s\n\tor individually per file with:\n\tgit add \u003cchanged file name\u003e\n\nPush your changes to your GitHub fork\n\n\tgit push \u003cgithub-user\u003e \u003cbranch-name\u003e\n\nExample: git push git@github.com:\u003cyour username\u003e/go-netops-tutorials.git new_feature/awesome\n\nRaise a Pull Request\n\n\tgit pull-request\n\nor\n\nUse the [Github Pull Request Help](https://help.github.com/articles/using-pull-requests/)\n\nIf you need to make changes to your pull request in response to commets etc...\n\nCheckout your working branch\n\n\tgit checkout \u003cbranch-name-with-changes\u003e\n\nMake changes and then commit\n\n\tgit add --all\n\tgit commit --amend\n\tgit push --force\n\n\n### Example Pull Request CLI\n\nHere is the CLI from updating the README w/ instructions above\n\n\tgo-netops-tutorials # git checkout -b update/README\n\tM\tREADME.md\n\tSwitched to a new branch 'update/README'\n\n\tgo-netops-tutorials # git status\n\tOn branch update/README\n\tChanges to be committed:\n\t  (use \"git reset HEAD \u003cfile\u003e...\" to unstage)\n\t\n\t\tmodified:   README.md\n\t\n\tgo-netops-tutorials # git add README.md\n\n\tgo-netops-tutorials # git commit -m\"updated README\"  --signoff\n\t[update/README 433b6b5] updated README\n\t 1 file changed, 133 insertions(+)\n\n\tgo-netops-tutorials # git push git@github.com:nerdalert/go-netops-tutorials.git 'update/README'\n\tCounting objects: 5, done.\n\tDelta compression using up to 8 threads.\n\tCompressing objects: 100% (3/3), done.\n\tWriting objects: 100% (3/3), 1.94 KiB | 0 bytes/s, done.\n\tTotal 3 (delta 1), reused 0 (delta 0)\n\tTo git@github.com:nerdalert/go-netops-tutorials.git\n\t * [new branch]      update/README -\u003e update/README\n\n\t\nLastly, you can then go to your fork and Github will ask you to make a pull request. You simply compare your branch/fork to the destination branch such as 'master' and click create pull request.\n\nThanks for stopping by and have fun hacking! Go is really a game changer in my mind for netops dev with really good performance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdalert%2Fgo-netops-tutorials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdalert%2Fgo-netops-tutorials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdalert%2Fgo-netops-tutorials/lists"}