Skip to content

Commit

Permalink
ekit: add ToPtr function
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed Jun 12, 2022
1 parent a8dc2a7 commit 69fe766
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# 开发中
# 开发中
[ekit: add ToPtr function](https://github.com/gotomicro/ekit/pull/6)
6 changes: 1 addition & 5 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ name = "go"
enabled = true

[analyzers.meta]
import_root = "github.com/gotomicro/ego-kit"
import_root = "github.com/gotomicro/ekit"
dependencies_vendored = false

[[analyzers]]
name = "test-coverage"
enabled = true

[[analyzers]]
name = "sql"
enabled = true

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ assignees: ''
### 你排查的结果,或者你觉得可行的修复方案
> 可选。我们希望你能够尽量先排查问题,帮助我们减轻维护负担。这对于你个人能力提升同样是有帮助的。
### 你使用的是 ego-kit 哪个版本?
### 你使用的是 ekit 哪个版本?

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ assignees: ''
### 其它
> 任何你觉得有利于解决问题的补充说明
### 你使用的是 ego-kit 哪个版本?
### 你使用的是 ekit 哪个版本?

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ labels: question

### 你的问题

### 你使用的是 ego-kit 哪个版本?
### 你使用的是 ekit 哪个版本?

### 你设置的的 Go 环境?
> 上传 `go env` 的结果
4 changes: 2 additions & 2 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ linters:

linters-settings:
gci:
local-prefixes: github.com/gotomicro/ego-kit
local-prefixes: github.com/gotomicro/ekit
goimports:
local-prefixes: github.com/gotomicro/ego-kit
local-prefixes: github.com/gotomicro/ekit
1 change: 1 addition & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
branches:
- develop
- main
- dev

jobs:
changelog:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ name: Go

on:
push:
branches: [ main ]
branches: [ dev ]
pull_request:
branches: [ main ]
branches: [ dev ]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
branches:
- develop
- main
- dev
jobs:
check-license-lines:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .licenserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"**/*.go": "// Copyright 2021 gotomicro",
"**/*.{yml,toml}": "# Copyright 2021 gotomicro"
"**/*.{yml,toml}": "# Copyright 2021 gotomicro",
"**/*.sh": "# Copyright 2021 gotomicro"
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bench:
@go test -bench=. -benchmem ./...

test:
ut:
@go test -race ./...

setup:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# ego-kit
Stream API, Collection and ...
# ekit
泛型工具库
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/gotomicro/ego-kit
module github.com/gotomicro/ekit

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ExampleNew() {

// goos: linux
// goarch: amd64
// pkg: github.com/gotomicro/ego-kit/pkg/pool
// pkg: github.com/gotomicro/ekit/pkg/pool
// cpu: Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz
// BenchmarkPool_Get/Pool-12 9190246 130.0 ns/op 0 B/op 0 allocs/op
// BenchmarkPool_Get/sync.Pool-12 9102818 128.6 ns/op 0 B/op 0 allocs/op
Expand Down
19 changes: 19 additions & 0 deletions ptr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2021 gotomicro
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ekit

func ToPtr[T any](t T) *T {
return &t
}
26 changes: 26 additions & 0 deletions ptr_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2021 gotomicro
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ekit

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestToPtr(t *testing.T) {
i := 12
res := ToPtr[int](i)
assert.Equal(t, &i, res)
}

0 comments on commit 69fe766

Please sign in to comment.