File size: 3,525 Bytes
2ad46af
bfa91ad
2ad46af
 
 
 
 
 
 
 
bfa91ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ad46af
 
4de1ac9
2ad46af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4de1ac9
2ad46af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
license: other
language: go
pretty_name: go Code Dataset (go-codesearch-dataset-openV2)
tags:
- code
- go
- codesearchnet-format
- source-code
- documentation
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: validation
    path: data/validation-*
  - split: test
    path: data/test-*
dataset_info:
  features:
  - name: code
    dtype: string
  - name: docstring
    dtype: string
  - name: func_name
    dtype: string
  - name: language
    dtype: string
  - name: repo
    dtype: string
  - name: path
    dtype: string
  - name: url
    dtype: string
  - name: license
    dtype: string
  splits:
  - name: train
    num_bytes: 342049797
    num_examples: 388495
  - name: validation
    num_bytes: 33499822
    num_examples: 43941
  - name: test
    num_bytes: 1172721
    num_examples: 1736
  download_size: 96158755
  dataset_size: 376722340
---

# go Code Dataset (go-codesearch-dataset-open)

## Dataset Description

This dataset contains go methods (functions) along with their documentation comments (typically `#` comments preceding the `def` line), extracted from various GitHub repositories. It follows a format similar to CodeSearchNet.

### Features

The dataset includes the following features for each sample:

- `code`: The go method's source code (from `def` to `end`).
- `docstring`: The documentation comment associated with the method.
- `func_name`: The name of the method (function).
- `language`: The programming language (always `"go"`).
- `repo`: The full name of the source GitHub repository (e.g., `rails/rails`).
- `path`: The relative file path within the source repository.
- `url`: A GitHub URL pointing to the source file (usually on the master/main branch).
- `license`: The SPDX identifier of the license declared for the source repository (e.g., `MIT`, `Apache-2.0`, `go`, or `NO LICENSE`).

## Dataset Structure

The dataset is divided into the following splits:

- `train`: 388,495 examples
- `validation`: 43,941 examples
- `test`: 1,736 examples

**Total Examples:** 434,172

## Usage

You can load and use this dataset using the `datasets` library:

```python
from datasets import load_dataset

# Load the dataset from the Hugging Face Hub
dataset = load_dataset("Shuu12121/go-codesearch-dataset-open")

# Access a specific split (e.g., training split)
train_data = dataset["train"]

# Explore the data
print(f"Number of training samples: {len(train_data):,}")
print("\nFirst training sample:")
print(train_data[0])

# Example: Access code and docstring of the first sample
first_sample = train_data[0]
print("\nMethod Name:", first_sample['func_name'])
print("\nDocstring:\n", first_sample['docstring'])
# print("\nCode Snippet:\n", first_sample['code'][:500] + "...") # Print first 500 chars of code
```


## Licensing

The code snippets included in this dataset are sourced from various GitHub repositories under different licenses (MIT, Apache-2.0, go License, BSD clauses, etc.). **Each data sample contains a `license` field indicating the license of the source repository.** Users of this dataset should be aware of and respect the original licenses when using the code snippets. The dataset itself (the collection and organization) is provided under a permissive license, but the underlying code snippets retain their original licenses.

## Disclaimer

This dataset was generated through an automated process. While efforts were made to accurately extract methods and documentation, there might be errors or inaccuracies.