{"id":25929586,"url":"https://github.com/robtimus/go-optional","last_synced_at":"2026-06-08T00:31:09.426Z","repository":{"id":280145467,"uuid":"941112874","full_name":"robtimus/go-optional","owner":"robtimus","description":"Provides a simple implementation of optionals","archived":false,"fork":false,"pushed_at":"2026-04-18T11:59:39.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-18T13:28:32.792Z","etag":null,"topics":["golang","optional","optionals"],"latest_commit_sha":null,"homepage":"","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/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-01T14:18:10.000Z","updated_at":"2026-04-18T11:59:43.000Z","dependencies_parsed_at":"2025-03-01T15:29:00.384Z","dependency_job_id":"9da1c56c-9e33-45b4-aaaf-85187318b79b","html_url":"https://github.com/robtimus/go-optional","commit_stats":null,"previous_names":["robtimus/go-optional"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robtimus/go-optional","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fgo-optional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fgo-optional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fgo-optional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fgo-optional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/go-optional/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fgo-optional/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34043822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["golang","optional","optionals"],"created_at":"2025-03-03T22:08:08.318Z","updated_at":"2026-06-08T00:31:09.420Z","avatar_url":"https://github.com/robtimus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-optional\n[![Build Status](https://github.com/robtimus/go-optional/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/go-optional/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=robtimus%3Ago-optional\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=robtimus%3Ago-optional)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=robtimus%3Ago-optional\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=robtimus%3Ago-optional)\n\nA simple implementation of optionals in Go, based on Java's [Optional](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Optional.html) class.\n\nMain differences:\n\n* In Go, only pointers can be `nil`. The function provided to the `Map` operation must return a value of the same type, and therefore will only result in an empty `Optional` if the receiver was already empty. The `MapNillable` operation is added that takes a function that returns a pointer to the `Optional`'s generic type.\n* Go does not support method generic types. That means that the `Optional` returned by `Map`, `MapNillable` and `FlatMap` operations cannot have a different generic type. To overcome this functions with the same name are provided that take the `Optional` as first argument. That does mean that method chaining is not always possible and needs to be replaced with call chaining:\n    ```go\n    // opt1 is some Optional\n    // func1 and func3 has different input and out types\n    // func2 has the same input and output types\n    opt2 := optional.Map(optional.Map(opt1, func1).Map(func2), func3)\n    ```\n* Go does not support method overloading. Java's `orElseThrow` is implemented in three ways:\n    * `OrElsePanic` panics if called on an empty `Optional`.\n    * `OrElseError` returns a default error if called on an empty `Optional`.\n    * `OrElseSupplyError` returns an error provided by a function if called on an empty `Optional`.\n* Go does not have the concept of streams the way that Java does. Java's `stream` operation has therefore been replaced by `Slice` that returns a slice with 0 or 1 elements, depending on the `Optional`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fgo-optional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Fgo-optional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fgo-optional/lists"}