Skip to content

proposal: Pipeline Operator for Go #68534

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
KINGMJ opened this issue Jul 21, 2024 · 3 comments
Closed

proposal: Pipeline Operator for Go #68534

KINGMJ opened this issue Jul 21, 2024 · 3 comments
Labels

Comments

@KINGMJ
Copy link

KINGMJ commented Jul 21, 2024

Proposal Details

Motivation

The pipeline operator (|>) is a feature seen in languages like Elixir, which allows for more readable and maintainable code by chaining function calls. Introducing a similar operator in Go can simplify complex function chains and improve code readability.

Proposal

Introduce a pipeline operator (|>) in Go that allows chaining function calls. The operator will pass the result of the expression on its left as the first argument to the function on its right.

Example

// Current Go code
result := multiplyByTwo(subtractThree(addOne(5)))

// Proposed syntax with pipeline operator
result := 5 |> addOne |> subtractThree |> multiplyByTwo
@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@mainjzb
Copy link

mainjzb commented Jul 21, 2024

If there is no error handling improvement, the scope of application is very limited.
I still hope that official can introduce some error handling improvement. The most likely scenario is an error handle macro.

@seankhliao
Copy link
Member

Duplicate of #33361

@seankhliao seankhliao marked this as a duplicate of #33361 Jul 21, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants