https://github.com/kubecub/typecheck
Typecheck is a github actions robust tool designed for cross-platform source code type checking across all Go build platforms. This utility leverages Go’s built-in parsing and type-check libraries (`go/parser` and `go/types`) to deliver efficient and reliable code analysis.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Keywords
Repository
Typecheck is a github actions robust tool designed for cross-platform source code type checking across all Go build platforms. This utility leverages Go’s built-in parsing and type-check libraries (`go/parser` and `go/types`) to deliver efficient and reliable code analysis.
Basic Info
Statistics
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 8
Topics
Metadata Files
README.md
Go Typecheck: Cross-Platform Source Code Type Checking for Go
Introduction
Go Typecheck is a robust tool designed for cross-platform source code type checking across all Go build platforms. This utility leverages Go’s built-in parsing and type-check libraries (go/parser and go/types) to deliver efficient and reliable code analysis.
Advantages
- Speed: A complete compilation with Go can take approximately 3 minutes. In contrast, Go Typecheck achieves this in mere seconds, significantly enhancing productivity.
- Resource Efficiency: Unlike the typical requirement of over 40GB of RAM for standard processes, Typecheck operates effectively with less than 8GB of RAM. This reduction in resource consumption makes it highly suitable for a variety of systems, reducing overheads and facilitating smoother operations.
Implementation
Go Typecheck employs Go's native parsing and type-checking libraries (go/parser and go/types). However, it's important to note that these libraries aren't identical to those used by the Go compiler. While occasional mismatches may occur, these libraries generally provide close approximations to the compiler's functionality, offering a reliable basis for type checking.
Error Handling
Typecheck's approach to error handling is pragmatic, focusing on practicality and build continuity.
Errors reported by go/types but not by go build:
- Actual Errors (as per the specification):
- These should ideally be rectified. If rectification is not feasible, such as in cases of ongoing work or external dependencies in the code, these errors can be overlooked.
- Example: Unused variables within a closure.
- False Positives:
- These errors should be ignored and, where appropriate, reported upstream for resolution.
- Example: Type mismatches between staging and generated types.
Errors reported by go build but not by us:
- CGo-related errors, including both syntax and linker issues, are outside our scope.
Usage
Github Actions
To integrate Go Code Typecheck into your GitHub Actions workflow, you can use the action available at the GitHub Marketplace. This action helps in performing type checks on your Go codebase, ensuring type safety and catching potential errors early in the development process.
Marketplace URL: Go Code Typecheck on GitHub Marketplace
GitHub Repository URL: kubecub/typecheck on GitHub
To use this action in your workflow, include the following step in your .github/workflows/<your-workflow>.yml file:
yml
- name: Go Code Typecheck
uses: kubecub/typecheck@v1.0.0
Full case presentation:
- Create a Workflow File: In your GitHub repository, create a new file in the .github/workflows directory. You can name it anything, but for clarity, we'll call it type-check.yml.
- Add Workflow Content: Copy the following YAML content into your type-check.yml file. This defines a workflow that uses the "Type Check" action on every push and pull_request event to your repository.
```yaml name: Go Type Check
on: [push, pull_request]
jobs: go-language-code-typechecker: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4
- name: Code Typecheck Detector
uses: kubecub/typecheck@main
```
The version of the action can be specified by using the tag associated with the desired release of kubecub/typecheck. For example, @v1.0.0 refers to version 0.1.3 of the action.
By incorporating this action into your workflow, you can automatically verify the type correctness of your Go code with every push or pull request, helping maintain code quality and reliability.
Locally
To run Typecheck locally, simply use the following command:
First, go to the repository of code you need to examine:
bash
go install github.com/kubecub/typecheck@latest
typecheck
Continuous Integration (CI)
In CI environments, Typecheck can be integrated into the workflow as follows:
yaml
- name: Typecheck
run: make verify
This streamlined process facilitates efficient error detection and resolution, ensuring a robust and reliable build pipeline.
More to learn about typecheck share blog
Owner
- Name: Kubernetes Cub community
- Login: kubecub
- Kind: organization
- Email: cub@nsddd.top
- Location: China
- Website: nsddd.top
- Twitter: xxw3293172751
- Repositories: 1
- Profile: https://github.com/kubecub
c-ub is a learning community for all, where you can find blockchain, operating systems, cloud-native projects, and a wide variety of resources and notebooks
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 10
proxy.golang.org: github.com/kubecub/typecheck
do a fast type check of openim code, for all platforms.
- Homepage: https://github.com/kubecub/typecheck
- Documentation: https://pkg.go.dev/github.com/kubecub/typecheck#section-documentation
- License: MIT
-
Latest release: v1.0.0
published almost 2 years ago