Skip to content

Request For Decorator Support #26328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Bowenwu1 opened this issue Jul 11, 2018 · 2 comments
Closed

Request For Decorator Support #26328

Bowenwu1 opened this issue Jul 11, 2018 · 2 comments

Comments

@Bowenwu1
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

I'm not sure.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wubowen/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wubowen/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_0/ktsbq1md4r31khrfz3tcq40r0000gn/T/go-build281190730=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Writing a Web Server.

What did you expect to see?

Nothing.

What did you see instead?

Nothing.

This is a not a bug report but an enhancement request.

What I want?

I want Go can support decorator just like in python, this is very helpful in server development!

For example, I want to refuse the unauth request for some method. Then, I must write many redundancy code to check auth state.

Just like python:

@login_required(login_url='/accounts/login/')
def my_view(request):
    ...
@ghost
Copy link

ghost commented Jul 11, 2018

Related: #15398

@ianlancetaylor
Copy link
Contributor

If you want to propose a change to the language, please follow the proposal process outlined at https://github.com/golang/proposal/blob/master/README.md . If you want to discuss ideas about how to add decorators to Go, please use the golang-nuts mailing list. I'm going to close this issue because there isn't enough information here to act on. We need more than just the suggestion of decorators; we need syntax, discussion of pros and cons, etc. Unfortunately we don't have time or knowledge to do that work for you just based on the mere suggestion. Thanks.

@golang golang locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants