fix golang code http method

I'm trying to figure out the best way to handle requests to / and only / in Go and handle different methods in different ways. Here's the best I've come up with:

package main

import (






func main() {

[login to view URL]("/", func(w [login to view URL], r *[login to view URL]) {

if [login to view URL] != "/" {

[login to view URL](w, r)



if [login to view URL] == "GET" {

[login to view URL](w, "GET, %q", [login to view URL]([login to view URL]))

} else if [login to view URL] == "POST" {

[login to view URL](w, "POST, %q", [login to view URL]([login to view URL]))

} else {

[login to view URL](w, "Invalid request method.", 405)



[login to view URL]([login to view URL](":8080", nil))


Is this idiomatic Go? Is this the best I can do with the standard http lib? I'd much rather do something like [login to view URL]("/", handler) as in express or Sinatra. Is there a good framework for writing simple REST services? [login to view URL] looks attractive but appears stagnant.

Thank you for your advice.

Evner: Golang, HTML, Javascript, PHP, Python

Se mere: fix html code, fix perl code, keylogger source code http post, golang fasthttp example, golang http server post example, golang http request body, fasthttp vs net/http, golang http client timeout, golang http client, golang http post json, golang http redirect, fix banner code, fix php code, java code simplex method, check fix webpage code, clipshare cpaint error invalid http response code, form fix page code php html, html fix php code, source code http proxy server, cpaint error invalid http response code

Om arbejdsgiveren:
( 15 bedømmelser ) Pyeongtaeksi Gyeonggi-do, Korea, Republic of

Projekt ID: #17557110

Tildelt til:


Hi there .. you know what to do .. this is just some text to fulfill the minimum requirement of 100 characters

$20 USD på 1 dag
(34 bedømmelser)

3 freelancere byder i gennemsnit $28 på dette job


Dear Client, Greetings!! We have few queries kindly ping us. Thanks for giving us the opportunity to bid over the requirement. As per your requirement, you would like to develop a Website. We would like to share Flere

$25 USD in 10 dage
(21 bedømmelser)

Hi there, I am a fulltime freelance web & mobile app developer. I got lot of experience on both web & mobile app development, Good with HTML, CSS, JS for frontend website Love coding with PHP and MySQL as datab Flere

$40 USD in 7 dage
(0 bedømmelser)